1
0
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:
Roman Zeyde 2024-10-07 17:47:26 +03:00 committed by GitHub
commit e684635b4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);