Skip to content

Commit f636008

Browse files
committed
[net processing] Clarify UpdatedBlockTip()
1 parent 94d2cc3 commit f636008

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/net_processing.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,28 +1296,30 @@ void PeerManager::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInde
12961296
m_connman.SetBestHeight(pindexNew->nHeight);
12971297
SetServiceFlagsIBDCache(!fInitialDownload);
12981298

1299-
// Relay inventory, but don't relay old inventory during initial block download.
1300-
if (!fInitialDownload) {
1301-
// Find the hashes of all blocks that weren't previously in the best chain.
1302-
std::vector<uint256> vHashes;
1303-
const CBlockIndex *pindexToAnnounce = pindexNew;
1304-
while (pindexToAnnounce != pindexFork) {
1305-
vHashes.push_back(pindexToAnnounce->GetBlockHash());
1306-
pindexToAnnounce = pindexToAnnounce->pprev;
1307-
if (vHashes.size() == MAX_BLOCKS_TO_ANNOUNCE) {
1308-
// Limit announcements in case of a huge reorganization.
1309-
// Rely on the peer's synchronization mechanism in that case.
1310-
break;
1311-
}
1299+
// Don't relay inventory during initial block download.
1300+
if (fInitialDownload) return;
1301+
1302+
// Find the hashes of all blocks that weren't previously in the best chain.
1303+
std::vector<uint256> vHashes;
1304+
const CBlockIndex *pindexToAnnounce = pindexNew;
1305+
while (pindexToAnnounce != pindexFork) {
1306+
vHashes.push_back(pindexToAnnounce->GetBlockHash());
1307+
pindexToAnnounce = pindexToAnnounce->pprev;
1308+
if (vHashes.size() == MAX_BLOCKS_TO_ANNOUNCE) {
1309+
// Limit announcements in case of a huge reorganization.
1310+
// Rely on the peer's synchronization mechanism in that case.
1311+
break;
13121312
}
1313-
m_connman.ForEachNode([&vHashes](CNode* pnode) {
1314-
LOCK(pnode->cs_inventory);
1315-
for (const uint256& hash : reverse_iterate(vHashes)) {
1316-
pnode->vBlockHashesToAnnounce.push_back(hash);
1317-
}
1318-
});
1319-
m_connman.WakeMessageHandler();
13201313
}
1314+
1315+
// Relay to all peers
1316+
m_connman.ForEachNode([&vHashes](CNode* pnode) {
1317+
LOCK(pnode->cs_inventory);
1318+
for (const uint256& hash : reverse_iterate(vHashes)) {
1319+
pnode->vBlockHashesToAnnounce.push_back(hash);
1320+
}
1321+
});
1322+
m_connman.WakeMessageHandler();
13211323
}
13221324

13231325
/**

0 commit comments

Comments
 (0)