Make EthApi client, pool, network and state accessors public (#1988)

This commit is contained in:
Gaon3
2023-03-26 17:02:35 +03:00
committed by GitHub
parent 00f691a58c
commit 8e6214768f

View File

@@ -82,17 +82,17 @@ impl<Client, Pool, Network> EthApi<Client, Pool, Network> {
}
/// 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<ChainState<'_>> {
pub fn state_at_block_id(&self, at: BlockId) -> EthResult<ChainState<'_>> {
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<BlockId>,
) -> EthResult<ChainState<'_>> {
@@ -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<Option<ChainState<'_>>> {
pub fn state_at_block_number(&self, num: BlockNumberOrTag) -> Result<Option<ChainState<'_>>> {
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<<Client as StateProviderFactory>::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<ChainState<'_>> {
pub fn state_at_number(&self, block_number: u64) -> Result<ChainState<'_>> {
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<<Client as StateProviderFactory>::LatestSP<'_>> {
pub fn latest_state(&self) -> Result<<Client as StateProviderFactory>::LatestSP<'_>> {
self.client().latest()
}
}