Skip to content

Commit aa3fa24

Browse files
committed
Implemented method to get private watchedAddressesLeafKeys
1 parent 24058dc commit aa3fa24

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

statediff/builder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (sdb *builder) buildStateDiffWithIntermediateStateNodes(args types2.StateRo
202202
// a map of their leafkey to all the accounts that were touched and exist at A
203203
diffAccountsAtA, err := sdb.deletedOrUpdatedState(
204204
oldTrie.NodeIterator([]byte{}), newTrie.NodeIterator([]byte{}),
205-
diffAccountsAtB, diffPathsAtB, params.WatchedAddressesLeafKeys,
205+
diffAccountsAtB, diffPathsAtB, params.watchedAddressesLeafKeys,
206206
params.IntermediateStorageNodes, output)
207207
if err != nil {
208208
return fmt.Errorf("error collecting deletedOrUpdatedNodes: %v", err)
@@ -248,7 +248,7 @@ func (sdb *builder) buildStateDiffWithoutIntermediateStateNodes(args types2.Stat
248248
// and a slice of all the paths for the nodes in both of the above sets
249249
diffAccountsAtB, diffPathsAtB, err := sdb.createdAndUpdatedState(
250250
oldTrie.NodeIterator([]byte{}), newTrie.NodeIterator([]byte{}),
251-
params.WatchedAddressesLeafKeys)
251+
params.watchedAddressesLeafKeys)
252252
if err != nil {
253253
return fmt.Errorf("error collecting createdAndUpdatedNodes: %v", err)
254254
}
@@ -257,7 +257,7 @@ func (sdb *builder) buildStateDiffWithoutIntermediateStateNodes(args types2.Stat
257257
// a map of their leafkey to all the accounts that were touched and exist at A
258258
diffAccountsAtA, err := sdb.deletedOrUpdatedState(
259259
oldTrie.NodeIterator([]byte{}), newTrie.NodeIterator([]byte{}),
260-
diffAccountsAtB, diffPathsAtB, params.WatchedAddressesLeafKeys,
260+
diffAccountsAtB, diffPathsAtB, params.watchedAddressesLeafKeys,
261261
params.IntermediateStorageNodes, output)
262262
if err != nil {
263263
return fmt.Errorf("error collecting deletedOrUpdatedNodes: %v", err)

statediff/config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,21 @@ type Params struct {
5555
IncludeTD bool
5656
IncludeCode bool
5757
WatchedAddresses []common.Address
58-
WatchedAddressesLeafKeys map[common.Hash]struct{}
58+
watchedAddressesLeafKeys map[common.Hash]struct{}
5959
}
6060

6161
// ComputeWatchedAddressesLeafKeys populates a map with keys (Keccak256Hash) of each of the WatchedAddresses
6262
func (p *Params) ComputeWatchedAddressesLeafKeys() {
63-
p.WatchedAddressesLeafKeys = make(map[common.Hash]struct{}, len(p.WatchedAddresses))
63+
p.watchedAddressesLeafKeys = make(map[common.Hash]struct{}, len(p.WatchedAddresses))
6464
for _, address := range p.WatchedAddresses {
65-
p.WatchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
65+
p.watchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
6666
}
6767
}
6868

69+
func (p *Params) WatchedAddressesLeafKeys() map[common.Hash]struct{} {
70+
return p.watchedAddressesLeafKeys
71+
}
72+
6973
// ParamsWithMutex allows to lock the parameters while they are being updated | read from
7074
type ParamsWithMutex struct {
7175
Params

statediff/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ func (sds *Service) WatchAddress(operation types2.OperationType, args []types2.W
903903
// update in-memory params
904904
writeLoopParams.WatchedAddresses = append(writeLoopParams.WatchedAddresses, filteredAddresses...)
905905
funk.ForEach(filteredAddresses, func(address common.Address) {
906-
writeLoopParams.WatchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
906+
writeLoopParams.watchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
907907
})
908908
case types2.Remove:
909909
// get addresses from args
@@ -927,7 +927,7 @@ func (sds *Service) WatchAddress(operation types2.OperationType, args []types2.W
927927
// update in-memory params
928928
writeLoopParams.WatchedAddresses = addresses
929929
funk.ForEach(argAddresses, func(address common.Address) {
930-
delete(writeLoopParams.WatchedAddressesLeafKeys, crypto.Keccak256Hash(address.Bytes()))
930+
delete(writeLoopParams.watchedAddressesLeafKeys, crypto.Keccak256Hash(address.Bytes()))
931931
})
932932
case types2.Set:
933933
// get addresses from args

0 commit comments

Comments
 (0)