From 71b27394bb5e0c1b241ad1433aee5eb03190ee72 Mon Sep 17 00:00:00 2001 From: Ivan Belyakov Date: Sat, 9 Dec 2023 09:10:07 +0100 Subject: [PATCH] fix(wallet): fixed BalanceAt not called for all but first account when new blocks are searched --- services/wallet/transfer/commands_sequential.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/wallet/transfer/commands_sequential.go b/services/wallet/transfer/commands_sequential.go index e9bf0c692..f9f98f988 100644 --- a/services/wallet/transfer/commands_sequential.go +++ b/services/wallet/transfer/commands_sequential.go @@ -196,7 +196,7 @@ func (c *findNewBlocksCommand) findBlocksWithEthTransfers(parent context.Context var newFromBlock *Block var ethHeaders []*DBHeader - newFromBlock, ethHeaders, startBlockNum, err = c.fastIndex(parent, c.balanceCacher, fromBlock, to) + newFromBlock, ethHeaders, startBlockNum, err = c.fastIndex(parent, account, c.balanceCacher, fromBlock, to) if err != nil { log.Error("findNewBlocksCommand checkRange fastIndex", "err", err, "account", account, "chain", c.chainClient.NetworkID()) @@ -517,7 +517,7 @@ func (c *findBlocksCommand) checkRange(parent context.Context, from *big.Int, to account := c.accounts[0] fromBlock := &Block{Number: from} - newFromBlock, ethHeaders, startBlock, err := c.fastIndex(parent, c.balanceCacher, fromBlock, to) + newFromBlock, ethHeaders, startBlock, err := c.fastIndex(parent, account, c.balanceCacher, fromBlock, to) if err != nil { log.Error("findBlocksCommand checkRange fastIndex", "err", err, "account", account, "chain", c.chainClient.NetworkID()) @@ -592,11 +592,10 @@ func areAllHistoryBlocksLoadedForAddress(blockRangeDAO *BlockRangeSequentialDAO, // run fast indexing for every accont up to canonical chain head minus safety depth. // every account will run it from last synced header. -func (c *findBlocksCommand) fastIndex(ctx context.Context, bCacher balance.Cacher, +func (c *findBlocksCommand) fastIndex(ctx context.Context, account common.Address, bCacher balance.Cacher, fromBlock *Block, toBlockNumber *big.Int) (resultingFrom *Block, headers []*DBHeader, startBlock *big.Int, err error) { - account := c.accounts[0] log.Debug("fast index started", "chainID", c.chainClient.NetworkID(), "account", account, "from", fromBlock.Number, "to", toBlockNumber)