feat: add BlockchainProvider type (#2294)

This commit is contained in:
Matthias Seitz
2023-04-24 14:54:09 +02:00
committed by GitHub
parent 16ce944ee5
commit 20e842b5b7
12 changed files with 754 additions and 393 deletions

View File

@ -10,7 +10,6 @@ use reth_primitives::{
};
use reth_provider::{
providers::PostStateProvider, BlockExecutor, Chain, ExecutorFactory, PostStateDataProvider,
StateProviderFactory,
};
use std::{
collections::BTreeMap,
@ -163,7 +162,7 @@ impl AppendableChain {
let history_provider = db.history_by_block_number(canonical_fork.number)?;
let state_provider = history_provider;
let provider = PostStateProvider { state_provider, post_state_data_provider };
let provider = PostStateProvider::new(state_provider, post_state_data_provider);
let mut executor = externals.executor_factory.with_sp(&provider);
executor.execute_and_verify_receipt(&unseal, U256::MAX, Some(senders)).map_err(Into::into)

View File

@ -1,4 +1,5 @@
//! Wrapper around BlockchainTree that allows for it to be shared.
use super::BlockchainTree;
use parking_lot::RwLock;
use reth_db::database::Database;
use reth_interfaces::{
@ -17,8 +18,6 @@ use std::{
sync::Arc,
};
use super::BlockchainTree;
/// Shareable blockchain tree that is behind tokio::RwLock
#[derive(Clone)]
pub struct ShareableBlockchainTree<DB: Database, C: Consensus, EF: ExecutorFactory> {
@ -119,7 +118,7 @@ impl<DB: Database, C: Consensus, EF: ExecutorFactory> BlockchainTreePendingState
impl<DB: Database, C: Consensus, EF: ExecutorFactory> CanonStateSubscriptions
for ShareableBlockchainTree<DB, C, EF>
{
fn subscribe_canon_state(&self) -> reth_provider::CanonStateNotifications {
fn subscribe_to_canonical_state(&self) -> reth_provider::CanonStateNotifications {
self.tree.read().subscribe_canon_state()
}
}