Skip to content

Commit dd5b011

Browse files
committed
[Trivial] add comment about setting peer as HB peer.
This adds a comment to the new logic for setting HB peers based on block validation (and aligns the code below to reflect the comment). It's not obvious why we're checking mapBlocksInFlight. Add a comment to explain.
1 parent af01cd3 commit dd5b011

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/net_processing.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,15 @@ void PeerLogicValidation::BlockChecked(const CBlock& block, const CValidationSta
865865
Misbehaving(it->second.first, nDoS);
866866
}
867867
}
868-
else if (state.IsValid() && !IsInitialBlockDownload() && mapBlocksInFlight.count(hash) == mapBlocksInFlight.size()) {
868+
// Check that:
869+
// 1. The block is valid
870+
// 2. We're not in initial block download
871+
// 3. This is currently the best block we're aware of. We haven't updated
872+
// the tip yet so we have no way to check this directly here. Instead we
873+
// just check that there are currently no other blocks in flight.
874+
else if (state.IsValid() &&
875+
!IsInitialBlockDownload() &&
876+
mapBlocksInFlight.count(hash) == mapBlocksInFlight.size()) {
869877
if (it != mapBlockSource.end()) {
870878
MaybeSetPeerAsAnnouncingHeaderAndIDs(it->second.first, *connman);
871879
}

0 commit comments

Comments
 (0)