eth: make debug_StorageRangeAt take a block hash or number (#27328)

eth: make StorageRangeAt take a block hash or number

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
This commit is contained in:
jwasinger 2023-05-30 14:16:28 +02:00 committed by GitHub
parent 188817468e
commit d789c68b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -204,11 +204,16 @@ type storageEntry struct {
} }
// StorageRangeAt returns the storage at the given block height and transaction index. // StorageRangeAt returns the storage at the given block height and transaction index.
func (api *DebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { func (api *DebugAPI) StorageRangeAt(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) {
// Retrieve the block var block *types.Block
block := api.eth.blockchain.GetBlockByHash(blockHash)
block, err := api.eth.APIBackend.BlockByNumberOrHash(ctx, blockNrOrHash)
if err != nil {
return StorageRangeResult{}, err
}
if block == nil { if block == nil {
return StorageRangeResult{}, fmt.Errorf("block %#x not found", blockHash) return StorageRangeResult{}, fmt.Errorf("block %v not found", blockNrOrHash)
} }
_, _, statedb, release, err := api.eth.stateAtTransaction(ctx, block, txIndex, 0) _, _, statedb, release, err := api.eth.stateAtTransaction(ctx, block, txIndex, 0)
if err != nil { if err != nil {