Implemented method to get private watchedAddressesLeafKeys
This commit is contained in:
parent
2e79df1884
commit
a78d590b65
@ -55,17 +55,21 @@ type Params struct {
|
|||||||
IncludeTD bool
|
IncludeTD bool
|
||||||
IncludeCode bool
|
IncludeCode bool
|
||||||
WatchedAddresses []common.Address
|
WatchedAddresses []common.Address
|
||||||
WatchedAddressesLeafKeys map[common.Hash]struct{}
|
watchedAddressesLeafKeys map[common.Hash]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ComputeWatchedAddressesLeafKeys populates a map with keys (Keccak256Hash) of each of the WatchedAddresses
|
// ComputeWatchedAddressesLeafKeys populates a map with keys (Keccak256Hash) of each of the WatchedAddresses
|
||||||
func (p *Params) ComputeWatchedAddressesLeafKeys() {
|
func (p *Params) ComputeWatchedAddressesLeafKeys() {
|
||||||
p.WatchedAddressesLeafKeys = make(map[common.Hash]struct{}, len(p.WatchedAddresses))
|
p.watchedAddressesLeafKeys = make(map[common.Hash]struct{}, len(p.WatchedAddresses))
|
||||||
for _, address := range p.WatchedAddresses {
|
for _, address := range p.WatchedAddresses {
|
||||||
p.WatchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
|
p.watchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Params) WatchedAddressesLeafKeys() map[common.Hash]struct{} {
|
||||||
|
return p.watchedAddressesLeafKeys
|
||||||
|
}
|
||||||
|
|
||||||
// ParamsWithMutex allows to lock the parameters while they are being updated | read from
|
// ParamsWithMutex allows to lock the parameters while they are being updated | read from
|
||||||
type ParamsWithMutex struct {
|
type ParamsWithMutex struct {
|
||||||
Params
|
Params
|
||||||
|
@ -903,7 +903,7 @@ func (sds *Service) WatchAddress(operation types2.OperationType, args []types2.W
|
|||||||
// update in-memory params
|
// update in-memory params
|
||||||
writeLoopParams.WatchedAddresses = append(writeLoopParams.WatchedAddresses, filteredAddresses...)
|
writeLoopParams.WatchedAddresses = append(writeLoopParams.WatchedAddresses, filteredAddresses...)
|
||||||
funk.ForEach(filteredAddresses, func(address common.Address) {
|
funk.ForEach(filteredAddresses, func(address common.Address) {
|
||||||
writeLoopParams.WatchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
|
writeLoopParams.watchedAddressesLeafKeys[crypto.Keccak256Hash(address.Bytes())] = struct{}{}
|
||||||
})
|
})
|
||||||
case types2.Remove:
|
case types2.Remove:
|
||||||
// get addresses from args
|
// get addresses from args
|
||||||
@ -927,7 +927,7 @@ func (sds *Service) WatchAddress(operation types2.OperationType, args []types2.W
|
|||||||
// update in-memory params
|
// update in-memory params
|
||||||
writeLoopParams.WatchedAddresses = addresses
|
writeLoopParams.WatchedAddresses = addresses
|
||||||
funk.ForEach(argAddresses, func(address common.Address) {
|
funk.ForEach(argAddresses, func(address common.Address) {
|
||||||
delete(writeLoopParams.WatchedAddressesLeafKeys, crypto.Keccak256Hash(address.Bytes()))
|
delete(writeLoopParams.watchedAddressesLeafKeys, crypto.Keccak256Hash(address.Bytes()))
|
||||||
})
|
})
|
||||||
case types2.Set:
|
case types2.Set:
|
||||||
// get addresses from args
|
// get addresses from args
|
||||||
|
Loading…
Reference in New Issue
Block a user