Skip to content

Commit 6a22373

Browse files
committed
Merge #7960: Only use AddInventoryKnown for transactions
383fc10 Only use AddInventoryKnown for transactions (Suhas Daftuar)
2 parents b89ef13 + 383fc10 commit 6a22373

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
@@ -4822,7 +4822,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
48224822
const CInv &inv = vInv[nInv];
48234823

48244824
boost::this_thread::interruption_point();
4825-
pfrom->AddInventoryKnown(inv);
48264825

48274826
bool fAlreadyHave = AlreadyHave(inv);
48284827
LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
@@ -4852,6 +4851,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
48524851
}
48534852
else
48544853
{
4854+
pfrom->AddInventoryKnown(inv);
48554855
if (fBlocksOnly)
48564856
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
48574857
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
@@ -5239,10 +5239,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
52395239
CBlock block;
52405240
vRecv >> block;
52415241

5242-
CInv inv(MSG_BLOCK, block.GetHash());
5243-
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
5244-
5245-
pfrom->AddInventoryKnown(inv);
5242+
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
52465243

52475244
CValidationState state;
52485245
// Process all blocks from whitelisted peers, even if not requested,
@@ -5255,7 +5252,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
52555252
if (state.IsInvalid(nDoS)) {
52565253
assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
52575254
pfrom->PushMessage(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
5258-
state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash);
5255+
state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), block.GetHash());
52595256
if (nDoS > 0) {
52605257
LOCK(cs_main);
52615258
Misbehaving(pfrom->GetId(), nDoS);
@@ -5827,9 +5824,7 @@ bool SendMessages(CNode* pto)
58275824
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
58285825
}
58295826

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

0 commit comments

Comments
 (0)