Skip to content

Commit

Permalink
eth: make debug_StorageRangeAt take a block hash or number (ethereum#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
3 people authored and MoonShiesty committed Aug 30, 2023
1 parent e496937 commit fca6d56
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions eth/api_debug.go
Expand Up @@ -204,11 +204,16 @@ type storageEntry struct {
}

// 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) {
// Retrieve the block
block := api.eth.blockchain.GetBlockByHash(blockHash)
func (api *DebugAPI) StorageRangeAt(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) {
var block *types.Block

block, err := api.eth.APIBackend.BlockByNumberOrHash(ctx, blockNrOrHash)
if err != nil {
return StorageRangeResult{}, err
}

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)
if err != nil {
Expand Down

0 comments on commit fca6d56

Please sign in to comment.