Skip to content

Commit

Permalink
Merge pull request #2222 from subspace/improve-dsn-sync-security
Browse files Browse the repository at this point in the history
Improve DSN sync security
  • Loading branch information
nazar-pc authored Nov 13, 2023
2 parents 9e61bad + 74cc14d commit dd2a264
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,35 @@ impl<'a> SegmentHeaderDownloader<'a> {
let peer_count = peer_segment_headers.len();

if peer_count < required_peers {
if last_peers_count == 0 || last_peers_count != peer_count {
// If we've got nothing, we have to retry
if last_peers_count == 0 {
debug!(
%peer_count,
%required_peers,
%retry_attempt,
"Segment headers consensus requires more peers, will retry"
"Segment headers consensus requires some peers, will retry"
);

continue;
} else {
}
// If number of peers found increased, but there are still attempts left, do more attempts
if last_peers_count != peer_count && required_peers > 1 {
debug!(
%peer_count,
%required_peers,
%retry_attempt,
"Segment headers consensus requires more peers, but result is the same as \
last time, so continue with what we've got"
"Segment headers consensus requires more peers, will retry"
);

continue;
}

debug!(
%peer_count,
%required_peers,
%retry_attempt,
"Segment headers consensus requires more peers, but no attempts left, so continue as is"
);
}

// Calculate votes
Expand Down

0 comments on commit dd2a264

Please sign in to comment.