Skip to content

Commit

Permalink
feat: mempool sync wait for node initial sync (#4897)
Browse files Browse the repository at this point in the history
Description
---
Wait for mempool sync to start after the intial sync is done.
Fixes #4785

How Has This Been Tested?
---
Manually.
  • Loading branch information
Cifko authored Nov 8, 2022
1 parent 3d1a51c commit 5526721
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions base_layer/core/src/mempool/sync_protocol/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,23 @@ impl ServiceInitializer for MempoolSyncInitializer {
let base_node = handles.expect_handle::<LocalNodeCommsInterface>();

let mut status_watch = state_machine.get_status_info_watch();
if !status_watch.borrow().bootstrapped {
debug!(target: LOG_TARGET, "Waiting for node to bootstrap...");
if !status_watch.borrow().state_info.is_synced() {
debug!(target: LOG_TARGET, "Waiting for node to do initial sync...");
while status_watch.changed().await.is_ok() {
log_mdc::extend(mdc.clone());
if status_watch.borrow().bootstrapped {
debug!(target: LOG_TARGET, "Node bootstrapped. Starting mempool sync protocol");
if status_watch.borrow().state_info.is_synced() {
dbg!();
debug!(
target: LOG_TARGET,
"Initial sync is done. Starting mempool sync protocol"
);
break;
}
trace!(
target: LOG_TARGET,
"Mempool sync still on hold, waiting for bootstrap to finish",
"Mempool sync still on hold, waiting for node to do initial sync",
);
sleep(Duration::from_secs(1)).await;
sleep(Duration::from_secs(30)).await;
}
log_mdc::extend(mdc.clone());
}
Expand Down

0 comments on commit 5526721

Please sign in to comment.