Skip to content

Commit

Permalink
chore: apply same member order (#12253)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 1, 2024
1 parent 2758a56 commit c6b7408
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 95 deletions.
12 changes: 6 additions & 6 deletions crates/blockchain-tree/src/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ impl BlockchainTreeEngine for NoopBlockchainTree {
Ok(())
}

fn update_block_hashes_and_clear_buffered(
&self,
) -> Result<BTreeMap<BlockNumber, BlockHash>, CanonicalError> {
Ok(BTreeMap::new())
}

fn connect_buffered_blocks_to_canonical_hashes(&self) -> Result<(), CanonicalError> {
Ok(())
}

fn make_canonical(&self, block_hash: BlockHash) -> Result<CanonicalOutcome, CanonicalError> {
Err(BlockchainTreeError::BlockHashNotFoundInChain { block_hash }.into())
}

fn update_block_hashes_and_clear_buffered(
&self,
) -> Result<BTreeMap<BlockNumber, BlockHash>, CanonicalError> {
Ok(BTreeMap::new())
}
}

impl BlockchainTreeViewer for NoopBlockchainTree {
Expand Down
10 changes: 5 additions & 5 deletions crates/exex/exex/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ where
});
}

fn without_head(mut self) -> Self {
self.set_without_head();
self
}

fn set_with_head(&mut self, exex_head: ExExHead) {
let current = std::mem::replace(&mut self.inner, ExExNotificationsInner::Invalid);
self.inner = ExExNotificationsInner::WithHead(match current {
Expand All @@ -131,6 +126,11 @@ where
});
}

fn without_head(mut self) -> Self {
self.set_without_head();
self
}

fn with_head(mut self, exex_head: ExExHead) -> Self {
self.set_with_head(exex_head);
self
Expand Down
14 changes: 7 additions & 7 deletions crates/node/builder/src/builder/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
type Pool = C::Pool;
type Evm = C::Evm;
type Executor = C::Executor;
type Network = C::Network;
type Consensus = C::Consensus;
type Network = C::Network;

fn pool(&self) -> &Self::Pool {
self.components.pool()
Expand All @@ -110,8 +110,8 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
self.components.block_executor()
}

fn provider(&self) -> &Self::Provider {
&self.provider
fn consensus(&self) -> &Self::Consensus {
self.components.consensus()
}

fn network(&self) -> &Self::Network {
Expand All @@ -122,12 +122,12 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
self.components.payload_builder()
}

fn task_executor(&self) -> &TaskExecutor {
&self.task_executor
fn provider(&self) -> &Self::Provider {
&self.provider
}

fn consensus(&self) -> &Self::Consensus {
self.components.consensus()
fn task_executor(&self) -> &TaskExecutor {
&self.task_executor
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ where
{
type Provider = N::Provider;
type Pool = N::Pool;
type Network = <N as RpcNodeCore>::Network;
type Evm = <N as RpcNodeCore>::Evm;
type Network = <N as RpcNodeCore>::Network;

#[inline]
fn pool(&self) -> &Self::Pool {
Expand Down
14 changes: 7 additions & 7 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,27 @@ mod block_rlp {
}

impl Encodable for Block {
fn length(&self) -> usize {
let helper: HelperRef<'_, _> = self.into();
helper.length()
}

fn encode(&self, out: &mut dyn bytes::BufMut) {
let helper: HelperRef<'_, _> = self.into();
helper.encode(out)
}
}

impl Encodable for SealedBlock {
fn length(&self) -> usize {
let helper: HelperRef<'_, _> = self.into();
helper.length()
}
}

impl Encodable for SealedBlock {
fn encode(&self, out: &mut dyn bytes::BufMut) {
let helper: HelperRef<'_, _> = self.into();
helper.encode(out)
}

fn length(&self) -> usize {
let helper: HelperRef<'_, _> = self.into();
helper.length()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-eth-api/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ where
{
type Provider = T::Provider;
type Pool = T::Pool;
type Network = <T as FullNodeComponents>::Network;
type Evm = <T as FullNodeComponents>::Evm;
type Network = <T as FullNodeComponents>::Network;

#[inline]
fn pool(&self) -> &Self::Pool {
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ where
{
type Provider = Provider;
type Pool = Pool;
type Network = Network;
type Evm = EvmConfig;
type Network = Network;

fn pool(&self) -> &Self::Pool {
self.inner.pool()
Expand Down
10 changes: 5 additions & 5 deletions crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2055,18 +2055,18 @@ impl<TX: DbTx, N: NodeTypes> StageCheckpointReader for DatabaseProvider<TX, N> {
Ok(self.tx.get::<tables::StageCheckpoints>(id.to_string())?)
}

/// Get stage checkpoint progress.
fn get_stage_checkpoint_progress(&self, id: StageId) -> ProviderResult<Option<Vec<u8>>> {
Ok(self.tx.get::<tables::StageCheckpointProgresses>(id.to_string())?)
}

fn get_all_checkpoints(&self) -> ProviderResult<Vec<(String, StageCheckpoint)>> {
self.tx
.cursor_read::<tables::StageCheckpoints>()?
.walk(None)?
.collect::<Result<Vec<(String, StageCheckpoint)>, _>>()
.map_err(ProviderError::Database)
}

/// Get stage checkpoint progress.
fn get_stage_checkpoint_progress(&self, id: StageId) -> ProviderResult<Option<Vec<u8>>> {
Ok(self.tx.get::<tables::StageCheckpointProgresses>(id.to_string())?)
}
}

impl<TX: DbTxMut, N: NodeTypes> StageCheckpointWriter for DatabaseProvider<TX, N> {
Expand Down
58 changes: 29 additions & 29 deletions crates/storage/provider/src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,35 +601,6 @@ impl<N: ProviderNodeTypes> StateProviderFactory for BlockchainProvider<N> {
self.database.latest()
}

fn history_by_block_number(
&self,
block_number: BlockNumber,
) -> ProviderResult<StateProviderBox> {
trace!(target: "providers::blockchain", ?block_number, "Getting history by block number");
self.ensure_canonical_block(block_number)?;
self.database.history_by_block_number(block_number)
}

fn history_by_block_hash(&self, block_hash: BlockHash) -> ProviderResult<StateProviderBox> {
trace!(target: "providers::blockchain", ?block_hash, "Getting history by block hash");
self.database.history_by_block_hash(block_hash)
}

fn state_by_block_hash(&self, block: BlockHash) -> ProviderResult<StateProviderBox> {
trace!(target: "providers::blockchain", ?block, "Getting state by block hash");
let mut state = self.history_by_block_hash(block);

// we failed to get the state by hash, from disk, hash block be the pending block
if state.is_err() {
if let Ok(Some(pending)) = self.pending_state_by_hash(block) {
// we found pending block by hash
state = Ok(pending)
}
}

state
}

/// Returns a [`StateProviderBox`] indexed by the given block number or tag.
///
/// Note: if a number is provided this will only look at historical(canonical) state.
Expand Down Expand Up @@ -662,6 +633,35 @@ impl<N: ProviderNodeTypes> StateProviderFactory for BlockchainProvider<N> {
}
}

fn history_by_block_number(
&self,
block_number: BlockNumber,
) -> ProviderResult<StateProviderBox> {
trace!(target: "providers::blockchain", ?block_number, "Getting history by block number");
self.ensure_canonical_block(block_number)?;
self.database.history_by_block_number(block_number)
}

fn history_by_block_hash(&self, block_hash: BlockHash) -> ProviderResult<StateProviderBox> {
trace!(target: "providers::blockchain", ?block_hash, "Getting history by block hash");
self.database.history_by_block_hash(block_hash)
}

fn state_by_block_hash(&self, block: BlockHash) -> ProviderResult<StateProviderBox> {
trace!(target: "providers::blockchain", ?block, "Getting state by block hash");
let mut state = self.history_by_block_hash(block);

// we failed to get the state by hash, from disk, hash block be the pending block
if state.is_err() {
if let Ok(Some(pending)) = self.pending_state_by_hash(block) {
// we found pending block by hash
state = Ok(pending)
}
}

state
}

/// Returns the state provider for pending state.
///
/// If there's no pending block available then the latest state provider is returned:
Expand Down
24 changes: 12 additions & 12 deletions crates/storage/provider/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,18 +760,6 @@ impl StateProviderFactory for MockEthProvider {
Ok(Box::new(self.clone()))
}

fn history_by_block_number(&self, _block: BlockNumber) -> ProviderResult<StateProviderBox> {
Ok(Box::new(self.clone()))
}

fn history_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(self.clone()))
}

fn state_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(self.clone()))
}

fn state_by_block_number_or_tag(
&self,
number_or_tag: BlockNumberOrTag,
Expand All @@ -798,6 +786,18 @@ impl StateProviderFactory for MockEthProvider {
}
}

fn history_by_block_number(&self, _block: BlockNumber) -> ProviderResult<StateProviderBox> {
Ok(Box::new(self.clone()))
}

fn history_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(self.clone()))
}

fn state_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(self.clone()))
}

fn pending(&self) -> ProviderResult<StateProviderBox> {
Ok(Box::new(self.clone()))
}
Expand Down
32 changes: 16 additions & 16 deletions crates/storage/provider/src/test_utils/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,22 +465,6 @@ impl StateProviderFactory for NoopProvider {
Ok(Box::new(*self))
}

fn history_by_block_number(&self, _block: BlockNumber) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn history_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn state_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn pending(&self) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn state_by_block_number_or_tag(
&self,
number_or_tag: BlockNumberOrTag,
Expand All @@ -507,6 +491,22 @@ impl StateProviderFactory for NoopProvider {
}
}

fn history_by_block_number(&self, _block: BlockNumber) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn history_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn state_by_block_hash(&self, _block: BlockHash) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn pending(&self) -> ProviderResult<StateProviderBox> {
Ok(Box::new(*self))
}

fn pending_state_by_hash(&self, _block_hash: B256) -> ProviderResult<Option<StateProviderBox>> {
Ok(Some(Box::new(*self)))
}
Expand Down
8 changes: 4 additions & 4 deletions crates/trie/trie/src/hashed_cursor/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ pub struct NoopHashedAccountCursor;
impl HashedCursor for NoopHashedAccountCursor {
type Value = Account;

fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
fn seek(&mut self, _key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
Ok(None)
}

fn seek(&mut self, _key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
Ok(None)
}
}
Expand All @@ -49,11 +49,11 @@ pub struct NoopHashedStorageCursor;
impl HashedCursor for NoopHashedStorageCursor {
type Value = U256;

fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
fn seek(&mut self, _key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
Ok(None)
}

fn seek(&mut self, _key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
Ok(None)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/trie/trie/src/prefix_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ impl PrefixSet {
}

impl<'a> IntoIterator for &'a PrefixSet {
type IntoIter = std::slice::Iter<'a, reth_trie_common::Nibbles>;
type Item = &'a reth_trie_common::Nibbles;
type IntoIter = std::slice::Iter<'a, reth_trie_common::Nibbles>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
Expand Down

0 comments on commit c6b7408

Please sign in to comment.