Skip to content

Commit a00a20e

Browse files
committed
dumpblocks: cache get receipts by block support
1 parent 077c367 commit a00a20e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

util/util.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,19 @@ func GetBlockRangeInPages(ctx context.Context, from, to, pageSize uint64, c *eth
112112
return allBlocks, nil
113113
}
114114

115+
var getReceiptsByBlockIsSupported *bool
116+
115117
func GetReceipts(ctx context.Context, rawBlocks []*json.RawMessage, c *ethrpc.Client, batchSize uint64) ([]*json.RawMessage, error) {
116-
// check if get receipts by block is supported
117-
err := c.CallContext(ctx, nil, "eth_getBlockReceipts", "0x1")
118-
if err == nil {
118+
if getReceiptsByBlockIsSupported == nil {
119+
err := c.CallContext(ctx, nil, "eth_getBlockReceipts", "0x0")
120+
supported := err == nil
121+
getReceiptsByBlockIsSupported = &supported
122+
}
123+
124+
if getReceiptsByBlockIsSupported != nil && *getReceiptsByBlockIsSupported {
119125
return getReceiptsByBlock(ctx, rawBlocks, c, batchSize)
120126
}
121127

122-
log.Debug().Err(err).Msg("eth_getBlockReceipts not supported, falling back to eth_getTransactionReceipt")
123128
return getReceiptsByTx(ctx, rawBlocks, c, batchSize)
124129
}
125130

0 commit comments

Comments
 (0)