Skip to content

Commit 7229eb0

Browse files
committed
merge bitcoin#23042: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer
1 parent 05395ff commit 7229eb0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,6 +3831,12 @@ void PeerManagerImpl::ProcessMessage(
38313831
best_block = &inv.hash;
38323832
}
38333833
} else {
3834+
if (fBlocksOnly && NetMessageViolatesBlocksOnly(inv.GetCommand())) {
3835+
LogPrint(BCLog::NET, "%s (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.GetCommand(), inv.hash.ToString(), pfrom.GetId());
3836+
pfrom.fDisconnect = true;
3837+
return;
3838+
}
3839+
38343840
const bool fAlreadyHave = AlreadyHave(inv);
38353841
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
38363842
::g_stats_client->inc(strprintf("message.received.inv_%s", inv.GetCommand()), 1.0f);
@@ -3840,11 +3846,7 @@ void PeerManagerImpl::ProcessMessage(
38403846
};
38413847

38423848
AddKnownInv(*peer, inv.hash);
3843-
if (fBlocksOnly && NetMessageViolatesBlocksOnly(inv.GetCommand())) {
3844-
LogPrint(BCLog::NET, "%s (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.GetCommand(), inv.hash.ToString(), pfrom.GetId());
3845-
pfrom.fDisconnect = true;
3846-
return;
3847-
} else if (!fAlreadyHave) {
3849+
if (!fAlreadyHave) {
38483850
if (fBlocksOnly && inv.type == MSG_ISDLOCK) {
38493851
if (pfrom.GetCommonVersion() <= ADDRV2_PROTO_VERSION) {
38503852
// It's ok to receive these invs, we just ignore them

0 commit comments

Comments
 (0)