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

Don't sync mempool when not yet loaded

This commit is contained in:
Andrew Toth 2024-10-06 13:47:32 -04:00
parent 1d02f10ec3
commit 7bab1fd3ef
No known key found for this signature in database
GPG Key ID: 60007AFC8938B018
2 changed files with 18 additions and 0 deletions

View File

@ -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()

View File

@ -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);