Call method for computing watchedAddressesLeafKeys

This commit is contained in:
nabarun 2022-05-12 15:51:46 +05:30
parent 6ed1bc739d
commit 7c19e86698
2 changed files with 22 additions and 2 deletions

View File

@ -299,7 +299,7 @@ func (sdb *builder) buildStateDiff(args []iterPair, params sd.Params, output sdt
if params.IntermediateStateNodes {
diffAccountsAtB, diffPathsAtB, err = sdb.createdAndUpdatedStateWithIntermediateNodes(args[0], output)
} else {
diffAccountsAtB, diffPathsAtB, err = sdb.createdAndUpdatedState(args[0], params.WatchedAddressesLeafKeys)
diffAccountsAtB, diffPathsAtB, err = sdb.createdAndUpdatedState(args[0], params.WatchedAddressesLeafKeys())
}
if err != nil {
@ -308,7 +308,7 @@ func (sdb *builder) buildStateDiff(args []iterPair, params sd.Params, output sdt
// collect a slice of all the nodes that existed at a path in A that doesn't exist in B
// a map of their leafkey to all the accounts that were touched and exist at A
diffAccountsAtA, err := sdb.deletedOrUpdatedState(args[1], diffAccountsAtB, diffPathsAtB, params.WatchedAddressesLeafKeys, params.IntermediateStorageNodes, output)
diffAccountsAtA, err := sdb.deletedOrUpdatedState(args[1], diffAccountsAtB, diffPathsAtB, params.WatchedAddressesLeafKeys(), params.IntermediateStorageNodes, output)
if err != nil {
return fmt.Errorf("error collecting deletedOrUpdatedNodes: %v", err)
}

View File

@ -194,6 +194,10 @@ func (sds *Service) StateDiffAt(blockNumber uint64, params sd.Params) (*sd.Paylo
return nil, err
}
logrus.Infof("sending state diff at block %d", blockNumber)
// compute leaf keys of watched addresses in the params
params.ComputeWatchedAddressesLeafKeys()
if blockNumber == 0 {
return sds.processStateDiff(currentBlock, common.Hash{}, params)
}
@ -212,6 +216,10 @@ func (sds *Service) StateDiffFor(blockHash common.Hash, params sd.Params) (*sd.P
return nil, err
}
logrus.Infof("sending state diff at block %s", blockHash.Hex())
// compute leaf keys of watched addresses in the params
params.ComputeWatchedAddressesLeafKeys()
if currentBlock.NumberU64() == 0 {
return sds.processStateDiff(currentBlock, common.Hash{}, params)
}
@ -281,6 +289,10 @@ func (sds *Service) StateTrieAt(blockNumber uint64, params sd.Params) (*sd.Paylo
return nil, err
}
logrus.Infof("sending state trie at block %d", blockNumber)
// compute leaf keys of watched addresses in the params
params.ComputeWatchedAddressesLeafKeys()
return sds.processStateTrie(currentBlock, params)
}
@ -320,6 +332,10 @@ func (sds *Service) WriteStateDiffAt(blockNumber uint64, params sd.Params) error
if err != nil {
return err
}
// compute leaf keys of watched addresses in the params
params.ComputeWatchedAddressesLeafKeys()
parentRoot := common.Hash{}
if blockNumber != 0 {
parentBlock, err := sds.lvlDBReader.GetBlockByHash(currentBlock.ParentHash())
@ -341,6 +357,10 @@ func (sds *Service) WriteStateDiffFor(blockHash common.Hash, params sd.Params) e
if err != nil {
return err
}
// compute leaf keys of watched addresses in the params
params.ComputeWatchedAddressesLeafKeys()
parentRoot := common.Hash{}
if currentBlock.NumberU64() != 0 {
parentBlock, err := sds.lvlDBReader.GetBlockByHash(currentBlock.ParentHash())