Use watched addresses from direct indexing params in statediff APIs by default
This commit is contained in:
parent
7b4ef34de2
commit
209f7d37c2
@ -477,6 +477,13 @@ func (sds *Service) StateDiffAt(blockNumber uint64, params Params) (*Payload, er
|
|||||||
currentBlock := sds.BlockChain.GetBlockByNumber(blockNumber)
|
currentBlock := sds.BlockChain.GetBlockByNumber(blockNumber)
|
||||||
log.Info("sending state diff", "block height", blockNumber)
|
log.Info("sending state diff", "block height", blockNumber)
|
||||||
|
|
||||||
|
// use watched addresses from statediffing write loop if not provided
|
||||||
|
if params.WatchedAddresses == nil {
|
||||||
|
writeLoopParams.RLock()
|
||||||
|
params.WatchedAddresses = make([]common.Address, len(writeLoopParams.WatchedAddresses))
|
||||||
|
copy(params.WatchedAddresses, writeLoopParams.WatchedAddresses)
|
||||||
|
writeLoopParams.RUnlock()
|
||||||
|
}
|
||||||
// compute leaf paths of watched addresses in the params
|
// compute leaf paths of watched addresses in the params
|
||||||
params.ComputeWatchedAddressesLeafPaths()
|
params.ComputeWatchedAddressesLeafPaths()
|
||||||
|
|
||||||
@ -493,6 +500,13 @@ func (sds *Service) StateDiffFor(blockHash common.Hash, params Params) (*Payload
|
|||||||
currentBlock := sds.BlockChain.GetBlockByHash(blockHash)
|
currentBlock := sds.BlockChain.GetBlockByHash(blockHash)
|
||||||
log.Info("sending state diff", "block hash", blockHash)
|
log.Info("sending state diff", "block hash", blockHash)
|
||||||
|
|
||||||
|
// use watched addresses from statediffing write loop if not provided
|
||||||
|
if params.WatchedAddresses == nil {
|
||||||
|
writeLoopParams.RLock()
|
||||||
|
params.WatchedAddresses = make([]common.Address, len(writeLoopParams.WatchedAddresses))
|
||||||
|
copy(params.WatchedAddresses, writeLoopParams.WatchedAddresses)
|
||||||
|
writeLoopParams.RUnlock()
|
||||||
|
}
|
||||||
// compute leaf paths of watched addresses in the params
|
// compute leaf paths of watched addresses in the params
|
||||||
params.ComputeWatchedAddressesLeafPaths()
|
params.ComputeWatchedAddressesLeafPaths()
|
||||||
|
|
||||||
@ -777,6 +791,15 @@ func (sds *Service) StreamCodeAndCodeHash(blockNumber uint64, outChan chan<- typ
|
|||||||
// This operation cannot be performed back past the point of db pruning; it requires an archival node
|
// This operation cannot be performed back past the point of db pruning; it requires an archival node
|
||||||
// for historical data
|
// for historical data
|
||||||
func (sds *Service) WriteStateDiffAt(blockNumber uint64, params Params) error {
|
func (sds *Service) WriteStateDiffAt(blockNumber uint64, params Params) error {
|
||||||
|
log.Info("writing state diff at", "block height", blockNumber)
|
||||||
|
|
||||||
|
// use watched addresses from statediffing write loop if not provided
|
||||||
|
if params.WatchedAddresses == nil {
|
||||||
|
writeLoopParams.RLock()
|
||||||
|
params.WatchedAddresses = make([]common.Address, len(writeLoopParams.WatchedAddresses))
|
||||||
|
copy(params.WatchedAddresses, writeLoopParams.WatchedAddresses)
|
||||||
|
writeLoopParams.RUnlock()
|
||||||
|
}
|
||||||
// compute leaf paths of watched addresses in the params
|
// compute leaf paths of watched addresses in the params
|
||||||
params.ComputeWatchedAddressesLeafPaths()
|
params.ComputeWatchedAddressesLeafPaths()
|
||||||
|
|
||||||
@ -793,6 +816,15 @@ func (sds *Service) WriteStateDiffAt(blockNumber uint64, params Params) error {
|
|||||||
// This operation cannot be performed back past the point of db pruning; it requires an archival node
|
// This operation cannot be performed back past the point of db pruning; it requires an archival node
|
||||||
// for historical data
|
// for historical data
|
||||||
func (sds *Service) WriteStateDiffFor(blockHash common.Hash, params Params) error {
|
func (sds *Service) WriteStateDiffFor(blockHash common.Hash, params Params) error {
|
||||||
|
log.Info("writing state diff for", "block hash", blockHash)
|
||||||
|
|
||||||
|
// use watched addresses from statediffing write loop if not provided
|
||||||
|
if params.WatchedAddresses == nil {
|
||||||
|
writeLoopParams.RLock()
|
||||||
|
params.WatchedAddresses = make([]common.Address, len(writeLoopParams.WatchedAddresses))
|
||||||
|
copy(params.WatchedAddresses, writeLoopParams.WatchedAddresses)
|
||||||
|
writeLoopParams.RUnlock()
|
||||||
|
}
|
||||||
// compute leaf paths of watched addresses in the params
|
// compute leaf paths of watched addresses in the params
|
||||||
params.ComputeWatchedAddressesLeafPaths()
|
params.ComputeWatchedAddressesLeafPaths()
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ var (
|
|||||||
IncludeBlock: true,
|
IncludeBlock: true,
|
||||||
IncludeReceipts: true,
|
IncludeReceipts: true,
|
||||||
IncludeTD: true,
|
IncludeTD: true,
|
||||||
|
WatchedAddresses: []common.Address{},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user