mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: extract blockchaintree types to blockchain-tree-api crate (#8393)
This commit is contained in:
@ -12,8 +12,8 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-blockchain-tree-api.workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-interfaces.workspace = true
|
||||
reth-storage-errors.workspace = true
|
||||
reth-execution-errors.workspace = true
|
||||
reth-db.workspace = true
|
||||
|
||||
@ -5,14 +5,14 @@ use crate::{
|
||||
state::{BlockchainId, TreeState},
|
||||
AppendableChain, BlockIndices, BlockchainTreeConfig, BundleStateData, TreeExternals,
|
||||
};
|
||||
use reth_blockchain_tree_api::{
|
||||
error::{BlockchainTreeError, CanonicalError, InsertBlockError, InsertBlockErrorKind},
|
||||
BlockAttachment, BlockStatus, BlockValidationKind, CanonicalOutcome, InsertPayloadOk,
|
||||
};
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_db::database::Database;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_execution_errors::{BlockExecutionError, BlockValidationError};
|
||||
use reth_interfaces::blockchain_tree::{
|
||||
error::{BlockchainTreeError, CanonicalError, InsertBlockError, InsertBlockErrorKind},
|
||||
BlockAttachment, BlockStatus, BlockValidationKind, CanonicalOutcome, InsertPayloadOk,
|
||||
};
|
||||
use reth_primitives::{
|
||||
BlockHash, BlockNumHash, BlockNumber, ForkBlock, GotExpected, Hardfork, PruneModes, Receipt,
|
||||
SealedBlock, SealedBlockWithSenders, SealedHeader, StaticFileSegment, B256, U256,
|
||||
|
||||
@ -5,14 +5,14 @@
|
||||
|
||||
use super::externals::TreeExternals;
|
||||
use crate::BundleStateDataRef;
|
||||
use reth_blockchain_tree_api::{
|
||||
error::{BlockchainTreeError, InsertBlockErrorKind},
|
||||
BlockAttachment, BlockValidationKind,
|
||||
};
|
||||
use reth_consensus::{Consensus, ConsensusError};
|
||||
use reth_db::database::Database;
|
||||
use reth_evm::execute::{BlockExecutionOutput, BlockExecutorProvider, Executor};
|
||||
use reth_execution_errors::BlockExecutionError;
|
||||
use reth_interfaces::blockchain_tree::{
|
||||
error::{BlockchainTreeError, InsertBlockErrorKind},
|
||||
BlockAttachment, BlockValidationKind,
|
||||
};
|
||||
use reth_primitives::{
|
||||
BlockHash, BlockNumber, ForkBlock, GotExpected, Receipts, SealedBlockWithSenders, SealedHeader,
|
||||
U256,
|
||||
|
||||
@ -18,6 +18,9 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
|
||||
/// Re-export of the blockchain tree API.
|
||||
pub use reth_blockchain_tree_api::*;
|
||||
|
||||
pub mod blockchain_tree;
|
||||
pub use blockchain_tree::BlockchainTree;
|
||||
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
use reth_interfaces::{
|
||||
blockchain_tree::{
|
||||
error::{BlockchainTreeError, CanonicalError, InsertBlockError},
|
||||
BlockValidationKind, BlockchainTreeEngine, BlockchainTreeViewer, CanonicalOutcome,
|
||||
InsertPayloadOk,
|
||||
},
|
||||
provider::ProviderError,
|
||||
RethResult,
|
||||
use reth_blockchain_tree_api::{
|
||||
self,
|
||||
error::{BlockchainTreeError, CanonicalError, InsertBlockError, ProviderError},
|
||||
BlockValidationKind, BlockchainTreeEngine, BlockchainTreeViewer, CanonicalOutcome,
|
||||
InsertPayloadOk,
|
||||
};
|
||||
use reth_primitives::{
|
||||
BlockHash, BlockNumHash, BlockNumber, Receipt, SealedBlock, SealedBlockWithSenders,
|
||||
@ -57,11 +54,11 @@ impl BlockchainTreeEngine for NoopBlockchainTree {
|
||||
fn connect_buffered_blocks_to_canonical_hashes_and_finalize(
|
||||
&self,
|
||||
_last_finalized_block: BlockNumber,
|
||||
) -> RethResult<()> {
|
||||
) -> Result<(), CanonicalError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn connect_buffered_blocks_to_canonical_hashes(&self) -> RethResult<()> {
|
||||
fn connect_buffered_blocks_to_canonical_hashes(&self) -> Result<(), CanonicalError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -71,7 +68,7 @@ impl BlockchainTreeEngine for NoopBlockchainTree {
|
||||
|
||||
fn update_block_hashes_and_clear_buffered(
|
||||
&self,
|
||||
) -> RethResult<BTreeMap<BlockNumber, BlockHash>> {
|
||||
) -> Result<BTreeMap<BlockNumber, BlockHash>, CanonicalError> {
|
||||
Ok(BTreeMap::new())
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,16 +2,13 @@
|
||||
|
||||
use super::BlockchainTree;
|
||||
use parking_lot::RwLock;
|
||||
use reth_blockchain_tree_api::{
|
||||
error::{CanonicalError, InsertBlockError},
|
||||
BlockValidationKind, BlockchainTreeEngine, BlockchainTreeViewer, CanonicalOutcome,
|
||||
InsertPayloadOk,
|
||||
};
|
||||
use reth_db::database::Database;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_interfaces::{
|
||||
blockchain_tree::{
|
||||
error::{CanonicalError, InsertBlockError},
|
||||
BlockValidationKind, BlockchainTreeEngine, BlockchainTreeViewer, CanonicalOutcome,
|
||||
InsertPayloadOk,
|
||||
},
|
||||
RethResult,
|
||||
};
|
||||
use reth_primitives::{
|
||||
BlockHash, BlockNumHash, BlockNumber, Receipt, SealedBlock, SealedBlockWithSenders,
|
||||
SealedHeader,
|
||||
@ -74,7 +71,7 @@ where
|
||||
fn connect_buffered_blocks_to_canonical_hashes_and_finalize(
|
||||
&self,
|
||||
last_finalized_block: BlockNumber,
|
||||
) -> RethResult<()> {
|
||||
) -> Result<(), CanonicalError> {
|
||||
trace!(target: "blockchain_tree", last_finalized_block, "Connecting buffered blocks to canonical hashes and finalizing the tree");
|
||||
let mut tree = self.tree.write();
|
||||
let res =
|
||||
@ -85,14 +82,14 @@ where
|
||||
|
||||
fn update_block_hashes_and_clear_buffered(
|
||||
&self,
|
||||
) -> RethResult<BTreeMap<BlockNumber, BlockHash>> {
|
||||
) -> Result<BTreeMap<BlockNumber, BlockHash>, CanonicalError> {
|
||||
let mut tree = self.tree.write();
|
||||
let res = tree.update_block_hashes_and_clear_buffered();
|
||||
tree.update_chains_metrics();
|
||||
Ok(res?)
|
||||
}
|
||||
|
||||
fn connect_buffered_blocks_to_canonical_hashes(&self) -> RethResult<()> {
|
||||
fn connect_buffered_blocks_to_canonical_hashes(&self) -> Result<(), CanonicalError> {
|
||||
trace!(target: "blockchain_tree", "Connecting buffered blocks to canonical hashes");
|
||||
let mut tree = self.tree.write();
|
||||
let res = tree.connect_buffered_blocks_to_canonical_hashes();
|
||||
|
||||
Reference in New Issue
Block a user