fix sync (#1643)
This commit is contained in:
parent
8949f4345f
commit
5f0da8aa71
@ -29,7 +29,12 @@ void CDSNotificationInterface::NotifyHeaderTip(const CBlockIndex *pindexNew, boo
|
|||||||
|
|
||||||
void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
|
void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
|
||||||
{
|
{
|
||||||
if (fInitialDownload || pindexNew == pindexFork) // In IBD or blocks were disconnected without any new ones
|
if (pindexNew == pindexFork) // blocks were disconnected without any new ones
|
||||||
|
return;
|
||||||
|
|
||||||
|
masternodeSync.UpdatedBlockTip(pindexNew, fInitialDownload, connman);
|
||||||
|
|
||||||
|
if (fInitialDownload) // In IBD
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mnodeman.UpdatedBlockTip(pindexNew);
|
mnodeman.UpdatedBlockTip(pindexNew);
|
||||||
|
@ -245,7 +245,7 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
|
|||||||
// b) we waited for at least MASTERNODE_SYNC_TIMEOUT_SECONDS since we reached
|
// b) we waited for at least MASTERNODE_SYNC_TIMEOUT_SECONDS since we reached
|
||||||
// the headers tip the last time (i.e. since we switched from
|
// the headers tip the last time (i.e. since we switched from
|
||||||
// MASTERNODE_SYNC_INITIAL to MASTERNODE_SYNC_WAITING and bumped time);
|
// MASTERNODE_SYNC_INITIAL to MASTERNODE_SYNC_WAITING and bumped time);
|
||||||
// c) there were no blocks (NotifyHeaderTip) or headers (AcceptedBlockHeader)
|
// c) there were no blocks (UpdatedBlockTip, NotifyHeaderTip) or headers (AcceptedBlockHeader)
|
||||||
// for at least MASTERNODE_SYNC_TIMEOUT_SECONDS.
|
// for at least MASTERNODE_SYNC_TIMEOUT_SECONDS.
|
||||||
// We must be at the tip already, let's move to the next asset.
|
// We must be at the tip already, let's move to the next asset.
|
||||||
SwitchToNextAsset(connman);
|
SwitchToNextAsset(connman);
|
||||||
@ -431,8 +431,26 @@ void CMasternodeSync::NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitia
|
|||||||
// Postpone timeout each time new block arrives while we are still syncing blockchain
|
// Postpone timeout each time new block arrives while we are still syncing blockchain
|
||||||
BumpAssetLastTime("CMasternodeSync::NotifyHeaderTip");
|
BumpAssetLastTime("CMasternodeSync::NotifyHeaderTip");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMasternodeSync::UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitialDownload, CConnman& connman)
|
||||||
|
{
|
||||||
|
LogPrint("mnsync", "CMasternodeSync::UpdatedBlockTip -- pindexNew->nHeight: %d fInitialDownload=%d\n", pindexNew->nHeight, fInitialDownload);
|
||||||
|
|
||||||
|
if (IsFailed() || IsSynced() || !pindexBestHeader)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!IsBlockchainSynced()) {
|
||||||
|
// Postpone timeout each time new block arrives while we are still syncing blockchain
|
||||||
|
BumpAssetLastTime("CMasternodeSync::UpdatedBlockTip");
|
||||||
|
}
|
||||||
|
|
||||||
if (fInitialDownload) {
|
if (fInitialDownload) {
|
||||||
|
// switched too early
|
||||||
|
if (IsBlockchainSynced()) {
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
// no need to check any further while still in IBD mode
|
// no need to check any further while still in IBD mode
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -452,7 +470,7 @@ void CMasternodeSync::NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitia
|
|||||||
|
|
||||||
fReachedBestHeader = fReachedBestHeaderNew;
|
fReachedBestHeader = fReachedBestHeaderNew;
|
||||||
|
|
||||||
LogPrint("mnsync", "CMasternodeSync::NotifyHeaderTip -- pindexNew->nHeight: %d pindexBestHeader->nHeight: %d fInitialDownload=%d fReachedBestHeader=%d\n",
|
LogPrint("mnsync", "CMasternodeSync::UpdatedBlockTip -- pindexNew->nHeight: %d pindexBestHeader->nHeight: %d fInitialDownload=%d fReachedBestHeader=%d\n",
|
||||||
pindexNew->nHeight, pindexBestHeader->nHeight, fInitialDownload, fReachedBestHeader);
|
pindexNew->nHeight, pindexBestHeader->nHeight, fInitialDownload, fReachedBestHeader);
|
||||||
|
|
||||||
if (!IsBlockchainSynced() && fReachedBestHeader) {
|
if (!IsBlockchainSynced() && fReachedBestHeader) {
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
|
|
||||||
void AcceptedBlockHeader(const CBlockIndex *pindexNew);
|
void AcceptedBlockHeader(const CBlockIndex *pindexNew);
|
||||||
void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload, CConnman& connman);
|
void NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload, CConnman& connman);
|
||||||
|
void UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitialDownload, CConnman& connman);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user