@@ -4822,7 +4822,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
4822
4822
const CInv &inv = vInv[nInv];
4823
4823
4824
4824
boost::this_thread::interruption_point ();
4825
- pfrom->AddInventoryKnown (inv);
4826
4825
4827
4826
bool fAlreadyHave = AlreadyHave (inv);
4828
4827
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,
4852
4851
}
4853
4852
else
4854
4853
{
4854
+ pfrom->AddInventoryKnown (inv);
4855
4855
if (fBlocksOnly )
4856
4856
LogPrint (" net" , " transaction (%s) inv sent in violation of protocol peer=%d\n " , inv.hash .ToString (), pfrom->id );
4857
4857
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload ())
@@ -5239,10 +5239,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
5239
5239
CBlock block;
5240
5240
vRecv >> block;
5241
5241
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 );
5246
5243
5247
5244
CValidationState state;
5248
5245
// Process all blocks from whitelisted peers, even if not requested,
@@ -5255,7 +5252,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
5255
5252
if (state.IsInvalid (nDoS)) {
5256
5253
assert (state.GetRejectCode () < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes
5257
5254
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 () );
5259
5256
if (nDoS > 0 ) {
5260
5257
LOCK (cs_main);
5261
5258
Misbehaving (pfrom->GetId (), nDoS);
@@ -5827,9 +5824,7 @@ bool SendMessages(CNode* pto)
5827
5824
hashToAnnounce.ToString (), chainActive.Tip ()->GetBlockHash ().ToString ());
5828
5825
}
5829
5826
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.
5833
5828
if (!PeerHasHeader (&state, pindex)) {
5834
5829
pto->PushInventory (CInv (MSG_BLOCK, hashToAnnounce));
5835
5830
LogPrint (" net" , " %s: sending inv peer=%d hash=%s\n " , __func__,
0 commit comments