From dec2f5a3b32de56f8fd6f06349c3c5c66159cae9 Mon Sep 17 00:00:00 2001 From: Delweng Date: Fri, 14 Jul 2023 15:57:09 +0800 Subject: [PATCH] turbo/jsonrpc: eth_getBlockReceipts support by by hash (#7886) Signed-off-by: jsvisa --- turbo/jsonrpc/eth_api.go | 2 +- turbo/jsonrpc/eth_receipts.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/turbo/jsonrpc/eth_api.go b/turbo/jsonrpc/eth_api.go index adaf60358..e87a71cfd 100644 --- a/turbo/jsonrpc/eth_api.go +++ b/turbo/jsonrpc/eth_api.go @@ -58,7 +58,7 @@ type EthAPI interface { // Receipt related (see ./eth_receipts.go) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) GetLogs(ctx context.Context, crit ethFilters.FilterCriteria) (types.Logs, error) - GetBlockReceipts(ctx context.Context, number rpc.BlockNumber) ([]map[string]interface{}, error) + GetBlockReceipts(ctx context.Context, numberOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error) // Uncle related (see ./eth_uncles.go) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error) diff --git a/turbo/jsonrpc/eth_receipts.go b/turbo/jsonrpc/eth_receipts.go index 23e1e17f7..39e1a5f8a 100644 --- a/turbo/jsonrpc/eth_receipts.go +++ b/turbo/jsonrpc/eth_receipts.go @@ -667,15 +667,14 @@ func (api *APIImpl) GetTransactionReceipt(ctx context.Context, txnHash common.Ha } // GetBlockReceipts - receipts for individual block -// func (api *APIImpl) GetBlockReceipts(ctx context.Context, number rpc.BlockNumber) ([]map[string]interface{}, error) { -func (api *APIImpl) GetBlockReceipts(ctx context.Context, number rpc.BlockNumber) ([]map[string]interface{}, error) { +func (api *APIImpl) GetBlockReceipts(ctx context.Context, numberOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err } defer tx.Rollback() - blockNum, blockHash, _, err := rpchelper.GetBlockNumber(rpc.BlockNumberOrHashWithNumber(number), tx, api.filters) + blockNum, blockHash, _, err := rpchelper.GetBlockNumber(numberOrHash, tx, api.filters) if err != nil { return nil, err }