mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Merge bitcoin/bitcoin#23042: net: Avoid logging AlreadyHaveTx when disconnecting misbehaving peer
fa2662c293
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: ACKfa2662c293
jnewbery: Code review ACKfa2662c293
dunxen: Concept and code review ACKfa2662c293
Tree-SHA512: 9996b807a824021f992b5281d82ff0cbbe6a442c2fedf7dfd6adda64ccc5e0ef4fb0ff91ab75086f975837bbbb7a5934ac7e671a80dcababa7203c92fc0c7f84
This commit is contained in:
commit
788909f3c7
1 changed files with 6 additions and 5 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue