Skip to content

Commit

Permalink
fix(proxy): block_transaction_count methods should return 0x0
Browse files Browse the repository at this point in the history
  • Loading branch information
tukan authored and 00nktk committed Nov 2, 2024
1 parent 48661bc commit 6502a33
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions proxy/src/rpc/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ impl EthApiServer for EthApiImpl {
use common::solana_sdk::hash::Hash;

let hash = Hash::new_from_array(hash.0);
self.get_block(db::BlockBy::Hash(hash), false, false)
.await
.map(|block| block.map(|block| U256::from(block.transactions.len())))
.map_err(Into::into)
Ok(Some(
self.get_block(db::BlockBy::Hash(hash), false, false)
.await
.map(|block| block.map(|block| U256::from(block.transactions.len())))
.map_err(Error::from)?
.unwrap_or(U256::ZERO),
))
}

/// Returns the number of transactions in a block matching the given block number.
Expand All @@ -124,16 +127,19 @@ impl EthApiServer for EthApiImpl {
number: BlockNumberOrTag,
) -> RpcResult<Option<U256>> {
let slot = self.find_slot(number).await?;
self.get_block(db::BlockBy::Slot(slot), false, number.is_pending())
.await
.map(|block| {
Some(
block
.map(|block| U256::from(block.transactions.len()))
.unwrap_or(U256::ZERO),
)
})
.map_err(Into::into)
Ok(Some(
self.get_block(db::BlockBy::Slot(slot), false, number.is_pending())
.await
.map(|block| {
Some(
block
.map(|block| U256::from(block.transactions.len()))
.unwrap_or(U256::ZERO),
)
})
.map_err(Error::from)?
.unwrap_or(U256::ZERO),
))
}

/// Returns the number of uncles in a block from a block matching the given block hash.
Expand Down

0 comments on commit 6502a33

Please sign in to comment.