Skip to content

Commit

Permalink
Pause crawler if mempool is disabled
Browse files Browse the repository at this point in the history
Implement waiting until the mempool becomes enabled, so that the crawler
does not run while the mempool is disabled.

If the `MempoolStatus` helper is unable to determine if the mempool is
enabled, stop the crawler task entirely.
  • Loading branch information
jvff committed Aug 30, 2021
1 parent faa40e0 commit 8a1c810
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions zebrad/src/components/mempool/crawler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,16 @@ where
}

/// Periodically crawl peers for transactions to include in the mempool.
pub async fn run(self) -> Result<(), BoxError> {
loop {
self.wait_until_enabled().await;
///
/// Runs until the [`SyncStatus`] loses its connection to the chain syncer, which happens when
/// Zebra is shutting down.
pub async fn run(mut self) -> Result<(), BoxError> {
while self.status.wait_until_close_to_tip().await.is_ok() {
self.crawl_transactions().await?;
sleep(RATE_LIMIT_DELAY).await;
}
}

/// Wait until the mempool is enabled.
async fn wait_until_enabled(&self) {
// TODO: Check if synchronizing up to chain tip has finished (#2603).
Ok(())
}

/// Crawl peers for transactions.
Expand Down

0 comments on commit 8a1c810

Please sign in to comment.