@@ -4765,7 +4765,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4765
4765
const CInv &inv = vInv[nInv];
4766
4766
4767
4767
boost::this_thread::interruption_point ();
4768
- pfrom->AddInventoryKnown (inv);
4769
4768
4770
4769
bool fAlreadyHave = AlreadyHave (inv);
4771
4770
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,
4795
4794
}
4796
4795
else
4797
4796
{
4797
+ pfrom->AddInventoryKnown (inv);
4798
4798
if (fBlocksOnly )
4799
4799
LogPrint (" net" , " transaction (%s) inv sent in violation of protocol peer=%d\n " , inv.hash .ToString (), pfrom->id );
4800
4800
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload ())
@@ -5173,10 +5173,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
5173
5173
CBlock block;
5174
5174
vRecv >> block;
5175
5175
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 );
5180
5177
5181
5178
CValidationState state;
5182
5179
// Process all blocks from whitelisted peers, even if not requested,
@@ -5189,7 +5186,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
5189
5186
if (state.IsInvalid (nDoS)) {
5190
5187
assert (state.GetRejectCode () < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
5191
5188
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 () );
5193
5190
if (nDoS > 0 ) {
5194
5191
LOCK (cs_main);
5195
5192
Misbehaving (pfrom->GetId (), nDoS);
@@ -5769,9 +5766,7 @@ bool SendMessages(CNode* pto)
5769
5766
hashToAnnounce.ToString (), chainActive.Tip ()->GetBlockHash ().ToString ());
5770
5767
}
5771
5768
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.
5775
5770
if (!PeerHasHeader (&state, pindex)) {
5776
5771
pto->PushInventory (CInv (MSG_BLOCK, hashToAnnounce));
5777
5772
LogPrint (" net" , " %s: sending inv peer=%d hash=%s\n " , __func__,
0 commit comments