diff --git a/src/daemon.rs b/src/daemon.rs index c0207b4..6270801 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -219,6 +219,12 @@ impl Daemon { .tx) } + pub(crate) fn get_mempool_info(&self) -> Result { + self.rpc + .get_mempool_info() + .context("failed to get mempool info") + } + pub(crate) fn get_mempool_txids(&self) -> Result> { self.rpc .get_raw_mempool() diff --git a/src/mempool.rs b/src/mempool.rs index 2612f23..8522ce6 100644 --- a/src/mempool.rs +++ b/src/mempool.rs @@ -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::::from_iter(self.entries.keys().copied()); let poll_result = MempoolSyncUpdate::poll(daemon, old_txids, exit_flag);