diff --git a/pbtc/util.rs b/pbtc/util.rs index 23d93bdf..79579999 100644 --- a/pbtc/util.rs +++ b/pbtc/util.rs @@ -5,7 +5,7 @@ use chain::RepresentH256; use {db, APP_INFO}; use config::Config; -pub fn open_db(_cfg: &Config) -> Arc { +pub fn open_db(_cfg: &Config) -> db::SharedStore { let db_path = app_dir(AppDataType::UserData, &APP_INFO, "db").expect("Failed to get app dir"); Arc::new(db::Storage::new(db_path).expect("Failed to open database")) } @@ -16,7 +16,7 @@ pub fn node_table_path() -> PathBuf { node_table } -pub fn init_db(cfg: &Config, db: &Arc) -> Result<(), String> { +pub fn init_db(cfg: &Config, db: &db::SharedStore) -> Result<(), String> { // insert genesis block if db is empty let genesis_block = cfg.magic.genesis_block(); match db.block_hash(0) { diff --git a/sync/src/blocks_writer.rs b/sync/src/blocks_writer.rs index f0cc0cb8..3f2f6816 100644 --- a/sync/src/blocks_writer.rs +++ b/sync/src/blocks_writer.rs @@ -10,7 +10,7 @@ pub struct BlocksWriter { } impl BlocksWriter { - pub fn new(storage: Arc) -> BlocksWriter { + pub fn new(storage: db::SharedStore) -> BlocksWriter { BlocksWriter { storage: storage.clone(), verifier: ChainVerifier::new(storage), diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 94f9f955..c03f214f 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -49,12 +49,12 @@ pub enum Error { } /// Create blocks writer. -pub fn create_sync_blocks_writer(db: Arc) -> blocks_writer::BlocksWriter { +pub fn create_sync_blocks_writer(db: db::SharedStore) -> blocks_writer::BlocksWriter { blocks_writer::BlocksWriter::new(db) } /// Create inbound synchronization connections factory for given `db`. -pub fn create_sync_connection_factory(handle: &Handle, consensus_params: ConsensusParams, db: Arc) -> p2p::LocalSyncNodeRef { +pub fn create_sync_connection_factory(handle: &Handle, consensus_params: ConsensusParams, db: db::SharedStore) -> p2p::LocalSyncNodeRef { use synchronization_chain::Chain as SyncChain; use synchronization_executor::LocalSynchronizationTaskExecutor as SyncExecutor; use local_node::LocalNode as SyncNode; diff --git a/sync/src/synchronization_chain.rs b/sync/src/synchronization_chain.rs index 4ef19907..8a0d2f6e 100644 --- a/sync/src/synchronization_chain.rs +++ b/sync/src/synchronization_chain.rs @@ -101,7 +101,7 @@ pub struct Chain { /// Best storage block (stored for optimizations) best_storage_block: db::BestBlock, /// Local blocks storage - storage: Arc, + storage: db::SharedStore, /// In-memory queue of blocks hashes hash_chain: HashQueueChain, /// In-memory queue of blocks headers @@ -134,7 +134,7 @@ impl BlockState { impl Chain { /// Create new `Chain` with given storage - pub fn new(storage: Arc) -> Self { + pub fn new(storage: db::SharedStore) -> Self { // we only work with storages with genesis block let genesis_block_hash = storage.block_hash(0) .expect("storage with genesis block is required"); @@ -165,7 +165,7 @@ impl Chain { } /// Get storage - pub fn storage(&self) -> Arc { + pub fn storage(&self) -> db::SharedStore { self.storage.clone() } @@ -666,6 +666,7 @@ mod tests { use primitives::hash::H256; use devtools::RandomTempPath; use test_data; + use db::BlockStapler; #[test] fn chain_empty() { diff --git a/sync/src/synchronization_client.rs b/sync/src/synchronization_client.rs index 601fbb89..5946ecef 100644 --- a/sync/src/synchronization_client.rs +++ b/sync/src/synchronization_client.rs @@ -1114,12 +1114,12 @@ pub mod tests { use db; use devtools::RandomTempPath; - fn create_disk_storage() -> Arc { + fn create_disk_storage() -> db::SharedStore { let path = RandomTempPath::create_dir(); Arc::new(db::Storage::new(path.as_path()).unwrap()) } - fn create_sync(storage: Option>) -> (Core, Handle, Arc>, ChainRef, Arc>>) { + fn create_sync(storage: Option) -> (Core, Handle, Arc>, ChainRef, Arc>>) { let event_loop = event_loop(); let handle = event_loop.handle(); let storage = match storage {