Skip to content

Commit 383fc10

Browse files
committed
Only use AddInventoryKnown for transactions
filterInventoryKnown is only used when relaying transactions, so stop adding block hashes to the filter.
1 parent e26b620 commit 383fc10

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/main.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,7 +4765,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
47654765
const CInv &inv = vInv[nInv];
47664766

47674767
boost::this_thread::interruption_point();
4768-
pfrom->AddInventoryKnown(inv);
47694768

47704769
bool fAlreadyHave = AlreadyHave(inv);
47714770
LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
@@ -4795,6 +4794,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
47954794
}
47964795
else
47974796
{
4797+
pfrom->AddInventoryKnown(inv);
47984798
if (fBlocksOnly)
47994799
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
48004800
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
@@ -5173,10 +5173,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
51735173
CBlock block;
51745174
vRecv >> block;
51755175

5176-
CInv inv(MSG_BLOCK, block.GetHash());
5177-
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
5178-
5179-
pfrom->AddInventoryKnown(inv);
5176+
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
51805177

51815178
CValidationState state;
51825179
// Process all blocks from whitelisted peers, even if not requested,
@@ -5189,7 +5186,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
51895186
if (state.IsInvalid(nDoS)) {
51905187
assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
51915188
pfrom->PushMessage(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
5192-
state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash);
5189+
state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), block.GetHash());
51935190
if (nDoS > 0) {
51945191
LOCK(cs_main);
51955192
Misbehaving(pfrom->GetId(), nDoS);
@@ -5769,9 +5766,7 @@ bool SendMessages(CNode* pto)
57695766
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
57705767
}
57715768

5772-
// If the peer announced this block to us, don't inv it back.
5773-
// (Since block announcements may not be via inv's, we can't solely rely on
5774-
// setInventoryKnown to track this.)
5769+
// If the peer's chain has this block, don't inv it back.
57755770
if (!PeerHasHeader(&state, pindex)) {
57765771
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
57775772
LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,

0 commit comments

Comments
 (0)