From 488295f56fc00699e5869cb63ad9bf2d6d0fed82 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Sun, 19 Mar 2023 17:06:24 +0200 Subject: [PATCH] chore(blockchain_tree): wrap tree database in `Arc` (#1843) --- crates/executor/src/blockchain_tree/externals.rs | 9 +++++++-- crates/executor/src/blockchain_tree/mod.rs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/executor/src/blockchain_tree/externals.rs b/crates/executor/src/blockchain_tree/externals.rs index 8df3f590f9..874760ff42 100644 --- a/crates/executor/src/blockchain_tree/externals.rs +++ b/crates/executor/src/blockchain_tree/externals.rs @@ -17,7 +17,7 @@ use std::sync::Arc; #[derive(Debug)] pub struct TreeExternals { /// The database, used to commit the canonical chain, or unwind it. - pub db: DB, + pub db: Arc, /// The consensus engine. pub consensus: C, /// The executor factory to execute blocks with. @@ -28,7 +28,12 @@ pub struct TreeExternals { impl TreeExternals { /// Create new tree externals. - pub fn new(db: DB, consensus: C, executor_factory: EF, chain_spec: Arc) -> Self { + pub fn new( + db: Arc, + consensus: C, + executor_factory: EF, + chain_spec: Arc, + ) -> Self { Self { db, consensus, executor_factory, chain_spec } } } diff --git a/crates/executor/src/blockchain_tree/mod.rs b/crates/executor/src/blockchain_tree/mod.rs index 521111ea84..481c60d77d 100644 --- a/crates/executor/src/blockchain_tree/mod.rs +++ b/crates/executor/src/blockchain_tree/mod.rs @@ -645,7 +645,7 @@ mod tests { fn setup_externals( exec_res: Vec, - ) -> TreeExternals>, Arc, TestExecutorFactory> { + ) -> TreeExternals, Arc, TestExecutorFactory> { let db = create_test_rw_db(); let consensus = Arc::new(TestConsensus::default()); let chain_spec = Arc::new(