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
+8
View File
@@ -26,6 +26,7 @@ use state_machine::ChangesTrieStorage as StateChangesTrieStorage;
use consensus::well_known_cache_keys;
use hash_db::Hasher;
use trie::MemoryDB;
use parking_lot::Mutex;
/// State of a new block.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -174,6 +175,13 @@ pub trait Backend<Block, H>: AuxStore + Send + Sync where
fn get_aux(&self, key: &[u8]) -> error::Result<Option<Vec<u8>>> {
AuxStore::get_aux(self, key)
}
/// Gain access to the import lock around this backend.
/// _Note_ Backend isn't expected to acquire the lock by itself ever. Rather
/// the using components should acquire and hold the lock whenever they do
/// something that the import of a block would interfere with, e.g. importing
/// a new block or calculating the best head.
fn get_import_lock(&self) -> &Mutex<()>;
}
/// Changes trie storage that supports pruning.