From 7229eb0ae231a1275e8ee484173990ef0e01ebc8 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:22:33 +0000 Subject: [PATCH] merge bitcoin#23042: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer --- src/net_processing.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index f78889857d..8bfbdefa14 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3831,6 +3831,12 @@ void PeerManagerImpl::ProcessMessage( best_block = &inv.hash; } } else { + if (fBlocksOnly && NetMessageViolatesBlocksOnly(inv.GetCommand())) { + LogPrint(BCLog::NET, "%s (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.GetCommand(), inv.hash.ToString(), pfrom.GetId()); + pfrom.fDisconnect = true; + return; + } + const bool fAlreadyHave = AlreadyHave(inv); LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId()); ::g_stats_client->inc(strprintf("message.received.inv_%s", inv.GetCommand()), 1.0f); @@ -3840,11 +3846,7 @@ void PeerManagerImpl::ProcessMessage( }; AddKnownInv(*peer, inv.hash); - if (fBlocksOnly && NetMessageViolatesBlocksOnly(inv.GetCommand())) { - LogPrint(BCLog::NET, "%s (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.GetCommand(), inv.hash.ToString(), pfrom.GetId()); - pfrom.fDisconnect = true; - return; - } else if (!fAlreadyHave) { + if (!fAlreadyHave) { if (fBlocksOnly && inv.type == MSG_ISDLOCK) { if (pfrom.GetCommonVersion() <= ADDRV2_PROTO_VERSION) { // It's ok to receive these invs, we just ignore them