Move import lock onto backend (#2797)

* Drop import_lock from client, move it into backend, impl default version via static mutex

* still need to allow depcretion because of client.backend

* additional docs

* Remove default impl of get_import_lock, impl on instances

* Bump parking_lot to 0.8.0 accross the board
This commit is contained in:
Benjamin Kampmann
2019-06-05 15:46:01 +02:00
committed by Bastian Köcher
parent 4f888f34d3
commit eaa0ab014a
37 changed files with 101 additions and 97 deletions
+7 -1
View File
@@ -18,7 +18,7 @@
use std::collections::HashMap;
use std::sync::Arc;
use parking_lot::RwLock;
use parking_lot::{RwLock, Mutex};
use primitives::{ChangesTrieConfiguration, storage::well_known_keys};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{
@@ -541,6 +541,7 @@ where
states: RwLock<HashMap<Block::Hash, InMemory<H>>>,
changes_trie_storage: ChangesTrieStorage<Block, H>,
blockchain: Blockchain<Block>,
import_lock: Mutex<()>,
}
impl<Block, H> Backend<Block, H>
@@ -555,6 +556,7 @@ where
states: RwLock::new(HashMap::new()),
changes_trie_storage: ChangesTrieStorage(InMemoryChangesTrieStorage::new()),
blockchain: Blockchain::new(),
import_lock: Default::default(),
}
}
}
@@ -684,6 +686,10 @@ where
fn revert(&self, _n: NumberFor<Block>) -> error::Result<NumberFor<Block>> {
Ok(Zero::zero())
}
fn get_import_lock(&self) -> &Mutex<()> {
&self.import_lock
}
}
impl<Block, H> backend::LocalBackend<Block, H> for Backend<Block, H>