fix: wait_for_min_peers shouldn't wait forever when all peers are in same work (#2340)
This commit is contained in:
@@ -77,18 +77,18 @@ impl SyncRunner {
|
||||
let mut n = 0;
|
||||
const MIN_PEERS: usize = 3;
|
||||
loop {
|
||||
let wp = self.peers.more_work_peers();
|
||||
let wp = self.peers.more_or_same_work_peers();
|
||||
// exit loop when:
|
||||
// * we have more than MIN_PEERS more_work peers
|
||||
// * we have more than MIN_PEERS more_or_same_work peers
|
||||
// * we are synced already, e.g. grin was quickly restarted
|
||||
// * timeout
|
||||
if wp.len() > MIN_PEERS
|
||||
|| (wp.len() == 0
|
||||
if wp > MIN_PEERS
|
||||
|| (wp == 0
|
||||
&& self.peers.enough_peers()
|
||||
&& head.total_difficulty > Difficulty::zero())
|
||||
|| n > wait_secs
|
||||
{
|
||||
if wp.len() > 0 || !global::is_production_mode() {
|
||||
if wp > 0 || !global::is_production_mode() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user