From 8e6214768f332dc2f13d6c9a4a480b173a9ef3a9 Mon Sep 17 00:00:00 2001 From: Gaon3 <89095198+Gaon3@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:02:35 +0300 Subject: [PATCH] Make EthApi client, pool, network and state accessors public (#1988) --- crates/rpc/rpc/src/eth/api/mod.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/rpc/rpc/src/eth/api/mod.rs b/crates/rpc/rpc/src/eth/api/mod.rs index 58bffeef1f..daa40db306 100644 --- a/crates/rpc/rpc/src/eth/api/mod.rs +++ b/crates/rpc/rpc/src/eth/api/mod.rs @@ -82,17 +82,17 @@ impl EthApi { } /// Returns the inner `Client` - pub(crate) fn client(&self) -> &Client { + pub fn client(&self) -> &Client { &self.inner.client } /// Returns the inner `Network` - pub(crate) fn network(&self) -> &Network { + pub fn network(&self) -> &Network { &self.inner.network } /// Returns the inner `Pool` - pub(crate) fn pool(&self) -> &Pool { + pub fn pool(&self) -> &Pool { &self.inner.pool } } @@ -108,7 +108,7 @@ where } /// Returns the state at the given [BlockId] enum. - pub(crate) fn state_at_block_id(&self, at: BlockId) -> EthResult> { + pub fn state_at_block_id(&self, at: BlockId) -> EthResult> { match at { BlockId::Hash(hash) => Ok(self.state_at_hash(hash.into()).map(ChainState::boxed)?), BlockId::Number(num) => { @@ -118,7 +118,7 @@ where } /// Returns the state at the given [BlockId] enum or the latest. - pub(crate) fn state_at_block_id_or_latest( + pub fn state_at_block_id_or_latest( &self, block_id: Option, ) -> EthResult> { @@ -132,10 +132,7 @@ where /// Returns the state at the given [BlockNumberOrTag] enum /// /// Returns `None` if no state available. - pub(crate) fn state_at_block_number( - &self, - num: BlockNumberOrTag, - ) -> Result>> { + pub fn state_at_block_number(&self, num: BlockNumberOrTag) -> Result>> { if let Some(number) = self.convert_block_number(num)? { self.state_at_number(number).map(Some) } else { @@ -144,7 +141,7 @@ where } /// Returns the state at the given block number - pub(crate) fn state_at_hash( + pub fn state_at_hash( &self, block_hash: H256, ) -> Result<::HistorySP<'_>> { @@ -152,7 +149,7 @@ where } /// Returns the state at the given block number - pub(crate) fn state_at_number(&self, block_number: u64) -> Result> { + pub fn state_at_number(&self, block_number: u64) -> Result> { match self.convert_block_number(BlockNumberOrTag::Latest)? { Some(num) if num == block_number => self.latest_state().map(ChainState::boxed), _ => self.client().history_by_block_number(block_number).map(ChainState::boxed), @@ -160,7 +157,7 @@ where } /// Returns the _latest_ state - pub(crate) fn latest_state(&self) -> Result<::LatestSP<'_>> { + pub fn latest_state(&self) -> Result<::LatestSP<'_>> { self.client().latest() } }