mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
fix: Fix panic when block receipts are called on non-existing blocks
This commit is contained in:
@ -32,6 +32,7 @@ use reth_rpc_eth_api::{
|
|||||||
helpers::{EthBlocks, EthTransactions, LoadReceipt},
|
helpers::{EthBlocks, EthTransactions, LoadReceipt},
|
||||||
transaction::ConvertReceiptInput,
|
transaction::ConvertReceiptInput,
|
||||||
};
|
};
|
||||||
|
use reth_rpc_eth_types::EthApiError;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::{marker::PhantomData, sync::Arc};
|
use std::{marker::PhantomData, sync::Arc};
|
||||||
use tokio_stream::{Stream, StreamExt};
|
use tokio_stream::{Stream, StreamExt};
|
||||||
@ -654,6 +655,9 @@ where
|
|||||||
block_id: BlockId,
|
block_id: BlockId,
|
||||||
) -> RpcResult<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>> {
|
) -> RpcResult<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>> {
|
||||||
trace!(target: "rpc::eth", ?block_id, "Serving eth_getBlockReceipts");
|
trace!(target: "rpc::eth", ?block_id, "Serving eth_getBlockReceipts");
|
||||||
|
if self.eth_api.provider().block_by_id(block_id).map_err(EthApiError::from)?.is_none() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
let result =
|
let result =
|
||||||
adjust_block_receipts(block_id, &*self.eth_api).instrument(engine_span!()).await?;
|
adjust_block_receipts(block_id, &*self.eth_api).instrument(engine_span!()).await?;
|
||||||
Ok(result.map(|(_, receipts)| receipts))
|
Ok(result.map(|(_, receipts)| receipts))
|
||||||
|
|||||||
Reference in New Issue
Block a user