Skip to content

Commit 788909f

Browse files
committed
Merge bitcoin/bitcoin#23042: net: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer
fa2662c net: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer (MarcoFalke) Pull request description: There is no need to log `AlreadyHaveTx` for an inv when a peer is marked for disconnection due to sending that inv. In fact, I find it confusing that a `block-relay-only` connection calls `AlreadyHaveTx` at all. Also there is no need to call `AddKnownTx` when the peer is marked for disconnection. ACKs for top commit: naumenkogs: ACK fa2662c jnewbery: Code review ACK fa2662c dunxen: Concept and code review ACK fa2662c Tree-SHA512: 9996b807a824021f992b5281d82ff0cbbe6a442c2fedf7dfd6adda64ccc5e0ef4fb0ff91ab75086f975837bbbb7a5934ac7e671a80dcababa7203c92fc0c7f84
2 parents c001da3 + fa2662c commit 788909f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,16 +2960,17 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
29602960
best_block = &inv.hash;
29612961
}
29622962
} else if (inv.IsGenTxMsg()) {
2963+
if (reject_tx_invs) {
2964+
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom.GetId());
2965+
pfrom.fDisconnect = true;
2966+
return;
2967+
}
29632968
const GenTxid gtxid = ToGenTxid(inv);
29642969
const bool fAlreadyHave = AlreadyHaveTx(gtxid);
29652970
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
29662971

29672972
pfrom.AddKnownTx(inv.hash);
2968-
if (reject_tx_invs) {
2969-
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom.GetId());
2970-
pfrom.fDisconnect = true;
2971-
return;
2972-
} else if (!fAlreadyHave && !m_chainman.ActiveChainstate().IsInitialBlockDownload()) {
2973+
if (!fAlreadyHave && !m_chainman.ActiveChainstate().IsInitialBlockDownload()) {
29732974
AddTxAnnouncement(pfrom, gtxid, current_time);
29742975
}
29752976
} else {

0 commit comments

Comments
 (0)