From 055d1fa32dc04212c8a1380a27dfb5abb4d6745d Mon Sep 17 00:00:00 2001 From: Bo QIU <35757521+boqiu@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:35:27 +0800 Subject: [PATCH] Fix sync state machine issue for sharding case (#102) * Fix sync state machine issue for sharding case * Fix fmt lint --- node/sync/src/controllers/serial.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/node/sync/src/controllers/serial.rs b/node/sync/src/controllers/serial.rs index 1fe2d8d..c13ec75 100644 --- a/node/sync/src/controllers/serial.rs +++ b/node/sync/src/controllers/serial.rs @@ -561,7 +561,10 @@ impl SerialSyncController { while !completed { match self.state { SyncState::Idle => { - if self.peers.count(&[Found, Connecting, Connected]) > 0 { + if self + .peers + .all_shards_available(vec![Found, Connecting, Connected]) + { self.state = SyncState::FoundPeers; } else { self.try_find_peers(); @@ -569,7 +572,10 @@ impl SerialSyncController { } SyncState::FindingPeers { since, .. } => { - if self.peers.count(&[Found, Connecting, Connected]) > 0 { + if self + .peers + .all_shards_available(vec![Found, Connecting, Connected]) + { self.state = SyncState::FoundPeers; } else { // storage node may not have the specific file when `FindFile`