1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Replace has_block() by read_header()

This commit is contained in:
Roman Zeyde 2018-04-11 20:41:09 +03:00
parent 611fce4dfb
commit 10d3182ee9
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB
2 changed files with 6 additions and 3 deletions

View File

@ -40,7 +40,7 @@ fn main() {
let mut store = Store::open("db/mainnet", StoreOptions { auto_compact: true });
loop {
if store.has_block(&waiter.wait()) {
if store.read_header(&waiter.wait()).is_some() {
continue;
}
index::update(&mut store, &daemon);

View File

@ -75,9 +75,12 @@ impl Store {
headers
}
pub fn has_block(&self, blockhash: &[u8]) -> bool {
pub fn read_header(&self, blockhash: &[u8]) -> Option<BlockHeader> {
let key: &[u8] = &[b"B", blockhash].concat();
self.db.get(key).unwrap().is_some()
self.db
.get(key)
.unwrap()
.map(|value| deserialize(&value).unwrap())
}
pub fn compact_if_needed(&self) {