From 38842531ca491d00dbe0beec7bdee26967814b1e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 16 Feb 2021 16:30:11 +0300 Subject: [PATCH] core: drop NEP5 tracker data if balance is zero Makes no sense storing it and returning to the user (C# plugin doesn't do that). --- pkg/core/blockchain.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 1e56785cc..1644f101b 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -945,8 +945,12 @@ func (bc *Blockchain) processNEP5Transfer(cache *dao.Cached, transfer *state.NEP } bs := balances.Trackers[transfer.Asset] bs.Balance -= transfer.Amount - bs.LastUpdatedBlock = transfer.Block - balances.Trackers[transfer.Asset] = bs + if bs.Balance != 0 { + bs.LastUpdatedBlock = transfer.Block + balances.Trackers[transfer.Asset] = bs + } else { + delete(balances.Trackers, transfer.Asset) + } transfer.Amount = -transfer.Amount isBig, err := cache.AppendNEP5Transfer(transfer.From, balances.NextTransferBatch, transfer)