Merge #7960: Only use AddInventoryKnown for transactions
383fc10 Only use AddInventoryKnown for transactions (Suhas Daftuar)
This commit is contained in:
parent
433a026a15
commit
bad08eadf8
@ -1396,6 +1396,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
pfrom->AddInventoryKnown(inv);
|
||||||
if (fBlocksOnly)
|
if (fBlocksOnly)
|
||||||
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
|
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
|
||||||
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
|
else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
|
||||||
@ -1864,10 +1865,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
CBlock block;
|
CBlock block;
|
||||||
vRecv >> block;
|
vRecv >> block;
|
||||||
|
|
||||||
CInv inv(MSG_BLOCK, block.GetHash());
|
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
|
||||||
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
|
|
||||||
|
|
||||||
pfrom->AddInventoryKnown(inv);
|
|
||||||
|
|
||||||
// Process all blocks from whitelisted peers, even if not requested,
|
// Process all blocks from whitelisted peers, even if not requested,
|
||||||
// unless we're still syncing with the network.
|
// unless we're still syncing with the network.
|
||||||
@ -2511,9 +2509,7 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsg
|
|||||||
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
|
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the peer announced this block to us, don't inv it back.
|
// If the peer's chain has this block, don't inv it back.
|
||||||
// (Since block announcements may not be via inv's, we can't solely rely on
|
|
||||||
// setInventoryKnown to track this.)
|
|
||||||
if (!PeerHasHeader(&state, pindex)) {
|
if (!PeerHasHeader(&state, pindex)) {
|
||||||
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
|
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
|
||||||
LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,
|
LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__,
|
||||||
|
@ -4376,6 +4376,7 @@ std::string GetWarnings(const std::string& strFor)
|
|||||||
assert(!"GetWarnings(): invalid parameter");
|
assert(!"GetWarnings(): invalid parameter");
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CBlockFileInfo::ToString() const {
|
std::string CBlockFileInfo::ToString() const {
|
||||||
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
|
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user