unique_repr, no default impl
This commit is contained in:
parent
444065e294
commit
92d8edc1a6
@ -225,7 +225,7 @@ impl<T> KeyDirectory for DiskDirectory<T> where T: KeyFileManager {
|
|||||||
Some(self)
|
Some(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash(&self) -> Result<u64, Error> {
|
fn unique_repr(&self) -> Result<u64, Error> {
|
||||||
self.files_hash()
|
self.files_hash()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,4 +95,8 @@ impl KeyDirectory for GethDirectory {
|
|||||||
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
|
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
|
||||||
self.dir.remove(account)
|
self.dir.remove(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn unique_repr(&self) -> Result<u64, Error> {
|
||||||
|
self.dir.unique_repr()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,5 +63,12 @@ impl KeyDirectory for MemoryDirectory {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn unique_repr(&self) -> Result<u64, Error> {
|
||||||
|
let mut val = 0u64;
|
||||||
|
let accounts = self.accounts.read();
|
||||||
|
for acc in accounts.keys() { val = val ^ ::util::FixedHash::low_u64(acc) }
|
||||||
|
Ok(val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ pub trait KeyDirectory: Send + Sync {
|
|||||||
fn path(&self) -> Option<&PathBuf> { None }
|
fn path(&self) -> Option<&PathBuf> { None }
|
||||||
/// Return vault provider, if available
|
/// Return vault provider, if available
|
||||||
fn as_vault_provider(&self) -> Option<&VaultKeyDirectoryProvider> { None }
|
fn as_vault_provider(&self) -> Option<&VaultKeyDirectoryProvider> { None }
|
||||||
/// Returns hash of the directory content, if supported
|
/// Unique representation of directory account collection
|
||||||
fn hash(&self) -> Result<u64, Error> { Ok(0u64) }
|
fn unique_repr(&self) -> Result<u64, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Vaults provider
|
/// Vaults provider
|
||||||
|
@ -74,4 +74,8 @@ impl KeyDirectory for ParityDirectory {
|
|||||||
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
|
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
|
||||||
self.dir.remove(account)
|
self.dir.remove(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn unique_repr(&self) -> Result<u64, Error> {
|
||||||
|
self.dir.unique_repr()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ impl EthMultiStore {
|
|||||||
|
|
||||||
fn reload_if_changed(&self) -> Result<(), Error> {
|
fn reload_if_changed(&self) -> Result<(), Error> {
|
||||||
let mut last_dir_hash = self.dir_hash.lock();
|
let mut last_dir_hash = self.dir_hash.lock();
|
||||||
let dir_hash = Some(self.dir.hash()?);
|
let dir_hash = Some(self.dir.unique_repr()?);
|
||||||
if *last_dir_hash == dir_hash {
|
if *last_dir_hash == dir_hash {
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
@ -74,4 +74,8 @@ impl KeyDirectory for TransientDir {
|
|||||||
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
|
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
|
||||||
self.dir.remove(account)
|
self.dir.remove(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn unique_repr(&self) -> Result<u64, Error> {
|
||||||
|
self.dir.unique_repr()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user