mirror of
https://github.com/romanz/electrs.git
synced 2025-02-22 14:33:09 +01:00
Don't sync mempool when not yet loaded
This commit is contained in:
parent
1d02f10ec3
commit
7bab1fd3ef
2 changed files with 18 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue