no need for write lock on txhashset for chain.is_unspent() (#2066)

* no need for write lock on txhashset

* commit
This commit is contained in:
Antioch Peverell
2018-12-03 09:35:40 +00:00
committed by GitHub
parent 8bad93c8c9
commit a24d613b05
3 changed files with 19 additions and 5 deletions
+14
View File
@@ -16,6 +16,7 @@
use std::marker;
use core::hash::Hash;
use core::pmmr::{is_leaf, Backend};
use ser::PMMRable;
@@ -70,4 +71,17 @@ where
None
}
}
/// Get the hash at provided position in the MMR.
pub fn get_hash(&self, pos: u64) -> Option<Hash> {
if pos > self.last_pos {
None
} else if is_leaf(pos) {
// If we are a leaf then get hash from the backend.
self.backend.get_hash(pos)
} else {
// If we are not a leaf get hash ignoring the remove log.
self.backend.get_from_file(pos)
}
}
}