aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-12-11 10:40:19 +0000
committerJohn Newbery <john@johnnewbery.com>2020-12-11 10:40:19 +0000
commitf6360088de8ca02f9d198da2f8cca4ea8d64c992 (patch)
tree0be5609078427d7388e1842eef5b1f3ceca376b9 /src/net_processing.cpp
parent94d2cc35be98d3b20db88b2a3745322e5b0aa9d4 (diff)
downloadbitcoin-f6360088de8ca02f9d198da2f8cca4ea8d64c992.tar.xz
[net processing] Clarify UpdatedBlockTip()
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index acacb7c592..7947470ba0 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1296,28 +1296,30 @@ void PeerManager::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInde
m_connman.SetBestHeight(pindexNew->nHeight);
SetServiceFlagsIBDCache(!fInitialDownload);
- // Relay inventory, but don't relay old inventory during initial block download.
- if (!fInitialDownload) {
- // Find the hashes of all blocks that weren't previously in the best chain.
- std::vector<uint256> vHashes;
- const CBlockIndex *pindexToAnnounce = pindexNew;
- while (pindexToAnnounce != pindexFork) {
- vHashes.push_back(pindexToAnnounce->GetBlockHash());
- pindexToAnnounce = pindexToAnnounce->pprev;
- if (vHashes.size() == MAX_BLOCKS_TO_ANNOUNCE) {
- // Limit announcements in case of a huge reorganization.
- // Rely on the peer's synchronization mechanism in that case.
- break;
- }
+ // Don't relay inventory during initial block download.
+ if (fInitialDownload) return;
+
+ // Find the hashes of all blocks that weren't previously in the best chain.
+ std::vector<uint256> vHashes;
+ const CBlockIndex *pindexToAnnounce = pindexNew;
+ while (pindexToAnnounce != pindexFork) {
+ vHashes.push_back(pindexToAnnounce->GetBlockHash());
+ pindexToAnnounce = pindexToAnnounce->pprev;
+ if (vHashes.size() == MAX_BLOCKS_TO_ANNOUNCE) {
+ // Limit announcements in case of a huge reorganization.
+ // Rely on the peer's synchronization mechanism in that case.
+ break;
}
- m_connman.ForEachNode([&vHashes](CNode* pnode) {
- LOCK(pnode->cs_inventory);
- for (const uint256& hash : reverse_iterate(vHashes)) {
- pnode->vBlockHashesToAnnounce.push_back(hash);
- }
- });
- m_connman.WakeMessageHandler();
}
+
+ // Relay to all peers
+ m_connman.ForEachNode([&vHashes](CNode* pnode) {
+ LOCK(pnode->cs_inventory);
+ for (const uint256& hash : reverse_iterate(vHashes)) {
+ pnode->vBlockHashesToAnnounce.push_back(hash);
+ }
+ });
+ m_connman.WakeMessageHandler();
}
/**