mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 01:43:29 +01:00
Merge pull request #1091 from andrewtoth/mempool-loaded
Don't sync mempool when not yet loaded
This commit is contained in:
commit
e684635b4b
@ -219,6 +219,12 @@ impl Daemon {
|
||||
.tx)
|
||||
}
|
||||
|
||||
pub(crate) fn get_mempool_info(&self) -> Result<json::GetMempoolInfoResult> {
|
||||
self.rpc
|
||||
.get_mempool_info()
|
||||
.context("failed to get mempool info")
|
||||
}
|
||||
|
||||
pub(crate) fn get_mempool_txids(&self) -> Result<Vec<Txid>> {
|
||||
self.rpc
|
||||
.get_raw_mempool()
|
||||
|
@ -211,6 +211,18 @@ impl Mempool {
|
||||
}
|
||||
|
||||
pub fn sync(&mut self, daemon: &Daemon, exit_flag: &ExitFlag) {
|
||||
let loaded = match daemon.get_mempool_info() {
|
||||
Ok(info) => info.loaded.unwrap_or(true),
|
||||
Err(e) => {
|
||||
warn!("mempool sync failed: {}", e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
if !loaded {
|
||||
warn!("mempool not loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
let old_txids = HashSet::<Txid>::from_iter(self.entries.keys().copied());
|
||||
|
||||
let poll_result = MempoolSyncUpdate::poll(daemon, old_txids, exit_flag);
|
||||
|
Loading…
Reference in New Issue
Block a user