aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorJohn Newbery <[email protected]>2020-06-20 23:16:20 -0400
committerJohn Newbery <[email protected]>2020-06-23 08:46:05 -0400
commit344e831de54f7b864f03a90f6cb19692eafcd463 (patch)
treeeedcd3d4c57ec38e884dade213a367f788085f28 /src/net_processing.cpp
parentMerge #19018: docs: fixing description of the field sequence in walletcreatef... (diff)
downloaddiscoin-344e831de54f7b864f03a90f6cb19692eafcd463.tar.xz
discoin-344e831de54f7b864f03a90f6cb19692eafcd463.zip
[net processing] Remove PushBlockInventory and PushBlockHash
PushBlockInventory() and PushBlockHash() are functions that can be replaced with single-line statements. This also eliminates the single place that cs_inventory is taken recursively.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index d7fbf6941..f678b73a4 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1328,9 +1328,10 @@ void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CB
}
// Relay inventory, but don't relay old inventory during initial block download.
connman->ForEachNode([nNewHeight, &vHashes](CNode* pnode) {
+ LOCK(pnode->cs_inventory);
if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 0)) {
for (const uint256& hash : reverse_iterate(vHashes)) {
- pnode->PushBlockHash(hash);
+ pnode->vBlockHashesToAnnounce.push_back(hash);
}
}
});
@@ -1607,7 +1608,7 @@ void static ProcessGetBlockData(CNode& pfrom, const CChainParams& chainparams, c
// Trigger the peer node to send a getblocks request for the next batch of inventory
if (inv.hash == pfrom.hashContinue)
{
- // Bypass PushBlockInventory, this must send even if redundant,
+ // Send immediately. This must send even if redundant,
// and we want it right after the last block so they don't
// wait for other stuff first.
std::vector<CInv> vInv;
@@ -2666,7 +2667,7 @@ void ProcessMessage(
LogPrint(BCLog::NET, " getblocks stopping, pruned or too old block at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
break;
}
- pfrom.PushBlockInventory(pindex->GetBlockHash());
+ WITH_LOCK(pfrom.cs_inventory, pfrom.vInventoryBlockToSend.push_back(pindex->GetBlockHash()));
if (--nLimit <= 0)
{
// When this block is requested, we'll send an inv that'll
@@ -4083,7 +4084,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
// If the peer's chain has this block, don't inv it back.
if (!PeerHasHeader(&state, pindex)) {
- pto->PushBlockInventory(hashToAnnounce);
+ pto->vInventoryBlockToSend.push_back(hashToAnnounce);
LogPrint(BCLog::NET, "%s: sending inv peer=%d hash=%s\n", __func__,
pto->GetId(), hashToAnnounce.ToString());
}