Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use block id for block receipts #5105

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/rpc/rpc-api/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ pub trait EthApi {

/// Returns all transaction receipts for a given block.
#[method(name = "getBlockReceipts")]
async fn block_receipts(
&self,
number: BlockNumberOrTag,
) -> RpcResult<Option<Vec<TransactionReceipt>>>;
async fn block_receipts(&self, block_id: BlockId)
-> RpcResult<Option<Vec<TransactionReceipt>>>;

/// Returns an uncle block of the given block and index.
#[method(name = "getUncleByBlockHashAndIndex")]
Expand Down
8 changes: 4 additions & 4 deletions crates/rpc/rpc/src/eth/api/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
EthApi,
};
use reth_network_api::NetworkInfo;
use reth_primitives::{BlockId, BlockNumberOrTag, TransactionMeta};
use reth_primitives::{BlockId, TransactionMeta};

use reth_provider::{BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
use reth_rpc_types::{Index, RichBlock, TransactionReceipt};
Expand Down Expand Up @@ -59,13 +59,13 @@ where
/// Returns `None` if the block wasn't found.
pub(crate) async fn block_receipts(
&self,
number: BlockNumberOrTag,
block_id: BlockId,
) -> EthResult<Option<Vec<TransactionReceipt>>> {
let mut block_and_receipts = None;

if number.is_pending() {
if block_id.is_pending() {
block_and_receipts = self.provider().pending_block_and_receipts()?;
} else if let Some(block_hash) = self.provider().block_hash_for_id(number.into())? {
} else if let Some(block_hash) = self.provider().block_hash_for_id(block_id)? {
block_and_receipts = self.cache().get_block_and_receipts(block_hash).await?;
}

Expand Down
9 changes: 3 additions & 6 deletions crates/rpc/rpc/src/eth/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,9 @@ where
}

/// Handler for: `eth_getBlockReceipts`
async fn block_receipts(
&self,
number: BlockNumberOrTag,
) -> Result<Option<Vec<TransactionReceipt>>> {
trace!(target: "rpc::eth", ?number, "Serving eth_getBlockReceipts");
Ok(EthApi::block_receipts(self, number).await?)
async fn block_receipts(&self, block_id: BlockId) -> Result<Option<Vec<TransactionReceipt>>> {
trace!(target: "rpc::eth", ?block_id, "Serving eth_getBlockReceipts");
Ok(EthApi::block_receipts(self, block_id).await?)
}

/// Handler for: `eth_getUncleByBlockHashAndIndex`
Expand Down
Loading