aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-10-22 19:07:28 +0800
committerfanquake <fanquake@gmail.com>2021-10-22 19:22:44 +0800
commit788909f3c79c00501c9e1656bdd685444c98255a (patch)
treee134e0f9f1689654c6ca60bb115d08b8bfcfb283 /src/net_processing.cpp
parentc001da306b29c46ef1e7421002c3aba3ff5ed514 (diff)
parentfa2662c293ec0aaa93092b59b6632f74729c4283 (diff)
downloadbitcoin-788909f3c79c00501c9e1656bdd685444c98255a.tar.xz
Merge bitcoin/bitcoin#23042: net: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer
fa2662c293ec0aaa93092b59b6632f74729c4283 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 fa2662c293ec0aaa93092b59b6632f74729c4283 jnewbery: Code review ACK fa2662c293ec0aaa93092b59b6632f74729c4283 dunxen: Concept and code review ACK fa2662c293ec0aaa93092b59b6632f74729c4283 Tree-SHA512: 9996b807a824021f992b5281d82ff0cbbe6a442c2fedf7dfd6adda64ccc5e0ef4fb0ff91ab75086f975837bbbb7a5934ac7e671a80dcababa7203c92fc0c7f84
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 9c8909f742..b9557c7dd2 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2960,16 +2960,17 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
best_block = &inv.hash;
}
} else if (inv.IsGenTxMsg()) {
+ if (reject_tx_invs) {
+ LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom.GetId());
+ pfrom.fDisconnect = true;
+ return;
+ }
const GenTxid gtxid = ToGenTxid(inv);
const bool fAlreadyHave = AlreadyHaveTx(gtxid);
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
pfrom.AddKnownTx(inv.hash);
- if (reject_tx_invs) {
- LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom.GetId());
- pfrom.fDisconnect = true;
- return;
- } else if (!fAlreadyHave && !m_chainman.ActiveChainstate().IsInitialBlockDownload()) {
+ if (!fAlreadyHave && !m_chainman.ActiveChainstate().IsInitialBlockDownload()) {
AddTxAnnouncement(pfrom, gtxid, current_time);
}
} else {