chore(blockchain_tree): wrap tree database in Arc (#1843)

This commit is contained in:
Roman Krasiuk
2023-03-19 17:06:24 +02:00
committed by GitHub
parent 274ab54703
commit 488295f56f
2 changed files with 8 additions and 3 deletions

View File

@ -17,7 +17,7 @@ use std::sync::Arc;
#[derive(Debug)]
pub struct TreeExternals<DB, C, EF> {
/// The database, used to commit the canonical chain, or unwind it.
pub db: DB,
pub db: Arc<DB>,
/// The consensus engine.
pub consensus: C,
/// The executor factory to execute blocks with.
@ -28,7 +28,12 @@ pub struct TreeExternals<DB, C, EF> {
impl<DB, C, EF> TreeExternals<DB, C, EF> {
/// Create new tree externals.
pub fn new(db: DB, consensus: C, executor_factory: EF, chain_spec: Arc<ChainSpec>) -> Self {
pub fn new(
db: Arc<DB>,
consensus: C,
executor_factory: EF,
chain_spec: Arc<ChainSpec>,
) -> Self {
Self { db, consensus, executor_factory, chain_spec }
}
}

View File

@ -645,7 +645,7 @@ mod tests {
fn setup_externals(
exec_res: Vec<PostState>,
) -> TreeExternals<Arc<Env<WriteMap>>, Arc<TestConsensus>, TestExecutorFactory> {
) -> TreeExternals<Env<WriteMap>, Arc<TestConsensus>, TestExecutorFactory> {
let db = create_test_rw_db();
let consensus = Arc::new(TestConsensus::default());
let chain_spec = Arc::new(