[net processing] Clarify UpdatedBlockTip()

This commit is contained in:
John Newbery 2020-12-11 10:40:19 +00:00
parent 94d2cc35be
commit f6360088de

View File

@ -1296,8 +1296,9 @@ void PeerManager::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInde
m_connman.SetBestHeight(pindexNew->nHeight); m_connman.SetBestHeight(pindexNew->nHeight);
SetServiceFlagsIBDCache(!fInitialDownload); SetServiceFlagsIBDCache(!fInitialDownload);
// Relay inventory, but don't relay old inventory during initial block download. // Don't relay inventory during initial block download.
if (!fInitialDownload) { if (fInitialDownload) return;
// Find the hashes of all blocks that weren't previously in the best chain. // Find the hashes of all blocks that weren't previously in the best chain.
std::vector<uint256> vHashes; std::vector<uint256> vHashes;
const CBlockIndex *pindexToAnnounce = pindexNew; const CBlockIndex *pindexToAnnounce = pindexNew;
@ -1310,6 +1311,8 @@ void PeerManager::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInde
break; break;
} }
} }
// Relay to all peers
m_connman.ForEachNode([&vHashes](CNode* pnode) { m_connman.ForEachNode([&vHashes](CNode* pnode) {
LOCK(pnode->cs_inventory); LOCK(pnode->cs_inventory);
for (const uint256& hash : reverse_iterate(vHashes)) { for (const uint256& hash : reverse_iterate(vHashes)) {
@ -1318,7 +1321,6 @@ void PeerManager::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInde
}); });
m_connman.WakeMessageHandler(); m_connman.WakeMessageHandler();
} }
}
/** /**
* Handle invalid block rejection and consequent peer discouragement, maintain which * Handle invalid block rejection and consequent peer discouragement, maintain which