Skip to content

Commit e5b2930

Browse files
ryanschneidersadoci
authored andcommitted
internal/ethapi: add debug_getRawReceipts RPC method (ethereum#24773)
Adds a method to retrieve all the binary encoded receipts from a block
1 parent 18065a3 commit e5b2930

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

internal/ethapi/api.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,33 @@ func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, number uint64) (hexu
19511951
return rlp.EncodeToBytes(block)
19521952
}
19531953

1954+
// GetRawReceipts retrieves the binary-encoded raw receipts of a single block.
1955+
func (api *PublicDebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]hexutil.Bytes, error) {
1956+
var hash common.Hash
1957+
if h, ok := blockNrOrHash.Hash(); ok {
1958+
hash = h
1959+
} else {
1960+
block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash)
1961+
if err != nil {
1962+
return nil, err
1963+
}
1964+
hash = block.Hash()
1965+
}
1966+
receipts, err := api.b.GetReceipts(ctx, hash)
1967+
if err != nil {
1968+
return nil, err
1969+
}
1970+
result := make([]hexutil.Bytes, len(receipts))
1971+
for i, receipt := range receipts {
1972+
b, err := receipt.MarshalBinary()
1973+
if err != nil {
1974+
return nil, err
1975+
}
1976+
result[i] = b
1977+
}
1978+
return result, nil
1979+
}
1980+
19541981
// PrintBlock retrieves a block and returns its pretty printed form.
19551982
func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) {
19561983
block, _ := api.b.BlockByNumber(ctx, rpc.BlockNumber(number))

internal/web3ext/web3ext.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ web3._extend({
297297
call: 'debug_getBlockRlp',
298298
params: 1
299299
}),
300+
new web3._extend.Method({
301+
name: 'getRawReceipts',
302+
call: 'debug_getRawReceipts',
303+
params: 1
304+
}),
300305
new web3._extend.Method({
301306
name: 'setHead',
302307
call: 'debug_setHead',

0 commit comments

Comments
 (0)