mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
eth/protocols: skip unavailable receipts
This commit is contained in:
parent
f63e9f3a80
commit
765a37f426
2 changed files with 15 additions and 4 deletions
|
|
@ -589,6 +589,11 @@ func testGetBlockReceipts(t *testing.T, protocol uint) {
|
|||
receipts rlp.RawList[*ReceiptList]
|
||||
)
|
||||
for i := uint64(0); i <= backend.chain.CurrentBlock().Number.Uint64(); i++ {
|
||||
if i == 1 {
|
||||
// Insert a missing block hash to verify the server returns a nil placeholder
|
||||
hashes = append(hashes, common.HexToHash("0xdeadbeef"))
|
||||
receipts.Append(nil)
|
||||
}
|
||||
block := backend.chain.GetBlockByNumber(i)
|
||||
hashes = append(hashes, block.Hash())
|
||||
br := backend.chain.GetReceiptsByHash(block.Hash())
|
||||
|
|
|
|||
|
|
@ -281,15 +281,18 @@ func ServiceGetReceiptsQuery69(chain *core.BlockChain, query GetReceiptsRequest)
|
|||
// Retrieve the requested block's receipts
|
||||
results := chain.GetReceiptsRLP(hash)
|
||||
if results == nil {
|
||||
continue // Can't retrieve the receipts, so we just skip this block.
|
||||
receipts.Append(nil)
|
||||
continue
|
||||
}
|
||||
body := chain.GetBodyRLP(hash)
|
||||
if body == nil {
|
||||
continue // The block body is missing, we also have to skip.
|
||||
receipts.Append(nil)
|
||||
continue
|
||||
}
|
||||
results, _, err := blockReceiptsToNetwork(results, body, receiptQueryParams{})
|
||||
if err != nil {
|
||||
log.Error("Error in block receipts conversion", "hash", hash, "err", err)
|
||||
receipts.Append(nil)
|
||||
continue
|
||||
}
|
||||
receipts.AppendRaw(results)
|
||||
|
|
@ -313,11 +316,13 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest,
|
|||
}
|
||||
results := chain.GetReceiptsRLP(hash)
|
||||
if results == nil {
|
||||
continue // Can't retrieve the receipts, so we just skip this block.
|
||||
receipts.Append(nil)
|
||||
continue
|
||||
}
|
||||
body := chain.GetBodyRLP(hash)
|
||||
if body == nil {
|
||||
continue // The block body is missing, we also have to skip.
|
||||
receipts.Append(nil)
|
||||
continue
|
||||
}
|
||||
q := receiptQueryParams{sizeLimit: uint64(maxPacketSize - bytes)}
|
||||
if i == 0 {
|
||||
|
|
@ -326,6 +331,7 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest,
|
|||
results, incomplete, err := blockReceiptsToNetwork(results, body, q)
|
||||
if err != nil {
|
||||
log.Error("Error in block receipts conversion", "hash", hash, "err", err)
|
||||
receipts.Append(nil)
|
||||
continue
|
||||
}
|
||||
if results == nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue