From 7808adea69e3e709e046d1b903a0e67a8b620285 Mon Sep 17 00:00:00 2001
From: Stanimal <sdbondi@users.noreply.github.com>
Date: Tue, 31 Aug 2021 14:45:20 +0400
Subject: [PATCH] tests: early subscription to connectivity events for mempool
 sync

---
 base_layer/core/src/mempool/sync_protocol/initializer.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/base_layer/core/src/mempool/sync_protocol/initializer.rs b/base_layer/core/src/mempool/sync_protocol/initializer.rs
index 535c32c77a..9af871121d 100644
--- a/base_layer/core/src/mempool/sync_protocol/initializer.rs
+++ b/base_layer/core/src/mempool/sync_protocol/initializer.rs
@@ -77,6 +77,8 @@ impl ServiceInitializer for MempoolSyncInitializer {
         context.spawn_until_shutdown(move |handles| async move {
             let state_machine = handles.expect_handle::<StateMachineHandle>();
             let connectivity = handles.expect_handle::<ConnectivityRequester>();
+            // Ensure that we get an subscription ASAP so that we don't miss any connectivity events
+            let connectivity_event_subscription = connectivity.get_event_subscription();
 
             let mut status_watch = state_machine.get_status_info_watch();
             if !status_watch.borrow().bootstrapped {
@@ -94,7 +96,7 @@ impl ServiceInitializer for MempoolSyncInitializer {
                 }
             }
 
-            MempoolSyncProtocol::new(config, notif_rx, connectivity.get_event_subscription(), mempool)
+            MempoolSyncProtocol::new(config, notif_rx, connectivity_event_subscription, mempool)
                 .run()
                 .await;
         });