core: record transfers even if 'from' balance is 0

Transfer events should still be saved even if balance tracking goes wild.
This commit is contained in:
Roman Khimov 2021-03-16 12:56:31 +03:00
parent 4a2bdf5ddc
commit 663f10192f

View file

@ -945,15 +945,14 @@ func (bc *Blockchain) processNEP5Transfer(cache *dao.Cached, transfer *state.NEP
return return
} }
bs := balances.Trackers[transfer.Asset] bs := balances.Trackers[transfer.Asset]
if bs.Balance == nil { if bs.Balance != nil {
return bs.Balance.Sub(bs.Balance, transfer.Amount)
} if bs.Balance.Sign() > 0 {
bs.Balance.Sub(bs.Balance, transfer.Amount) bs.LastUpdatedBlock = transfer.Block
if bs.Balance.Sign() > 0 { balances.Trackers[transfer.Asset] = bs
bs.LastUpdatedBlock = transfer.Block } else {
balances.Trackers[transfer.Asset] = bs delete(balances.Trackers, transfer.Asset)
} else { }
delete(balances.Trackers, transfer.Asset)
} }
transfer.Amount.Neg(transfer.Amount) transfer.Amount.Neg(transfer.Amount)