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:
parent
611fce4dfb
commit
10d3182ee9
@ -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);
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user