mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-15 12:40:41 +02:00
[net processing] Clarify UpdatedBlockTip()
This commit is contained in:
parent
94d2cc35be
commit
f6360088de
@ -1296,28 +1296,30 @@ 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.
|
|
||||||
std::vector<uint256> vHashes;
|
// Find the hashes of all blocks that weren't previously in the best chain.
|
||||||
const CBlockIndex *pindexToAnnounce = pindexNew;
|
std::vector<uint256> vHashes;
|
||||||
while (pindexToAnnounce != pindexFork) {
|
const CBlockIndex *pindexToAnnounce = pindexNew;
|
||||||
vHashes.push_back(pindexToAnnounce->GetBlockHash());
|
while (pindexToAnnounce != pindexFork) {
|
||||||
pindexToAnnounce = pindexToAnnounce->pprev;
|
vHashes.push_back(pindexToAnnounce->GetBlockHash());
|
||||||
if (vHashes.size() == MAX_BLOCKS_TO_ANNOUNCE) {
|
pindexToAnnounce = pindexToAnnounce->pprev;
|
||||||
// Limit announcements in case of a huge reorganization.
|
if (vHashes.size() == MAX_BLOCKS_TO_ANNOUNCE) {
|
||||||
// Rely on the peer's synchronization mechanism in that case.
|
// Limit announcements in case of a huge reorganization.
|
||||||
break;
|
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user