From e7effef052a0edbf9bba5b8f19fc214eb7cacc6b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 10 Nov 2022 14:53:58 +0300 Subject: [PATCH] core: reuse appendTokenTransferInfo from appendTokenTransfer --- pkg/core/blockchain.go | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index ebf2d22f2..8c919c7b6 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1852,34 +1852,29 @@ func appendTokenTransfer(cache *dao.Simple, transCache map[util.Uint160]transfer } var ( log *state.TokenTransferLog - newBatch *bool - nextBatch *uint32 - currTimestamp *uint64 + nextBatch uint32 + currTimestamp uint64 ) if !isNEP11 { log = &transferData.Log17 - newBatch = &transferData.Info.NewNEP17Batch - nextBatch = &transferData.Info.NextNEP17Batch - currTimestamp = &transferData.Info.NextNEP17NewestTimestamp + nextBatch = transferData.Info.NextNEP17Batch + currTimestamp = transferData.Info.NextNEP17NewestTimestamp } else { log = &transferData.Log11 - newBatch = &transferData.Info.NewNEP11Batch - nextBatch = &transferData.Info.NextNEP11Batch - currTimestamp = &transferData.Info.NextNEP11NewestTimestamp + nextBatch = transferData.Info.NextNEP11Batch + currTimestamp = transferData.Info.NextNEP11NewestTimestamp } err := log.Append(transfer) if err != nil { return err } - transferData.Info.LastUpdated[token] = bIndex - *newBatch = log.Size() >= state.TokenTransferBatchSize - if *newBatch { - cache.PutTokenTransferLog(addr, *currTimestamp, *nextBatch, isNEP11, log) - *nextBatch++ - *currTimestamp = bTimestamp + newBatch := log.Size() >= state.TokenTransferBatchSize + if newBatch { + cache.PutTokenTransferLog(addr, currTimestamp, nextBatch, isNEP11, log) // Put makes a copy of it anyway. log.Reset() } + appendTokenTransferInfo(&transferData.Info, token, bIndex, bTimestamp, isNEP11, newBatch) transCache[addr] = transferData return nil }