Merge pull request #1045 from UdjinM6/fixSync1

Various sync fixes
This commit is contained in:
Evan Duffield 2016-09-29 14:21:47 -07:00 committed by GitHub
commit bdf1a6d24d
5 changed files with 16 additions and 24 deletions

View File

@ -134,7 +134,6 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
if(mapSeenGovernanceObjects.count(govobj.GetHash())){ if(mapSeenGovernanceObjects.count(govobj.GetHash())){
// TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE? // TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE?
masternodeSync.AddedBudgetItem(govobj.GetHash());
return; return;
} }
@ -183,10 +182,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
// IF WE'VE SEEN THIS OBJECT THEN SKIP // IF WE'VE SEEN THIS OBJECT THEN SKIP
if(mapSeenVotes.count(vote.GetHash())){ if(mapSeenVotes.count(vote.GetHash())) return;
masternodeSync.AddedBudgetItem(vote.GetHash());
return;
}
// FIND THE MASTERNODE OF THE VOTER // FIND THE MASTERNODE OF THE VOTER

View File

@ -1817,7 +1817,7 @@ bool IsInitialBlockDownload()
if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints())) if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints()))
return true; return true;
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 || bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
pindexBestHeader->GetBlockTime() < GetTime() - chainParams.MaxTipAge()); std::max(chainActive.Tip()->GetBlockTime(), pindexBestHeader->GetBlockTime()) < GetTime() - chainParams.MaxTipAge());
if (!state) if (!state)
lockIBDState = true; lockIBDState = true;
return state; return state;

View File

@ -316,7 +316,6 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
if(mapMasternodePaymentVotes.count(vote.GetHash())) { if(mapMasternodePaymentVotes.count(vote.GetHash())) {
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- hash=%s, nHeight=%d seen\n", vote.GetHash().ToString(), pCurrentBlockIndex->nHeight); LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- hash=%s, nHeight=%d seen\n", vote.GetHash().ToString(), pCurrentBlockIndex->nHeight);
masternodeSync.AddedPaymentVote();
return; return;
} }

View File

@ -29,15 +29,14 @@ bool CMasternodeSync::IsBlockchainSynced()
lastProcess = GetTime(); lastProcess = GetTime();
if(fBlockchainSynced) return true; if(fBlockchainSynced) return true;
if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false;
if (fImporting || fReindex) return false; // same as !IsInitialBlockDownload() but no cs_main needed here
int nMaxBlockTime = std::max(pCurrentBlockIndex->GetBlockTime(), pindexBestHeader->GetBlockTime());
fBlockchainSynced = pindexBestHeader->nHeight - pCurrentBlockIndex->nHeight < 24 * 6 &&
GetTime() - nMaxBlockTime < Params().MaxTipAge();
if(!pCurrentBlockIndex) return false; return fBlockchainSynced;
if(pCurrentBlockIndex->nTime + 60*60 < GetTime()) return false;
fBlockchainSynced = true;
return true;
} }
void CMasternodeSync::Fail() void CMasternodeSync::Fail()
@ -204,7 +203,9 @@ void CMasternodeSync::ProcessTick()
TRY_LOCK(cs_vNodes, lockRecv); TRY_LOCK(cs_vNodes, lockRecv);
if(!lockRecv) return; if(!lockRecv) return;
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_INITIAL) { if(nRequestedMasternodeAssets == MASTERNODE_SYNC_INITIAL ||
(nRequestedMasternodeAssets == MASTERNODE_SYNC_SPORKS && IsBlockchainSynced()))
{
SwitchToNextAsset(); SwitchToNextAsset();
} }
@ -246,10 +247,6 @@ void CMasternodeSync::ProcessTick()
netfulfilledman.AddFulfilledRequest(pnode->addr, "spork-sync"); netfulfilledman.AddFulfilledRequest(pnode->addr, "spork-sync");
// get current network sporks // get current network sporks
pnode->PushMessage(NetMsgType::GETSPORKS); pnode->PushMessage(NetMsgType::GETSPORKS);
// we always ask for sporks, so just skip this
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_SPORKS) SwitchToNextAsset();
continue; // always get sporks first, switch to the next node without waiting for the next tick continue; // always get sporks first, switch to the next node without waiting for the next tick
} }

View File

@ -701,7 +701,6 @@ int CMasternodeMan::GetEstimatedMasternodes(int nBlock)
void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) { void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) {
mapSeenMasternodePing.insert(make_pair(mnb.lastPing.GetHash(), mnb.lastPing)); mapSeenMasternodePing.insert(make_pair(mnb.lastPing.GetHash(), mnb.lastPing));
mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb)); mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
masternodeSync.AddedMasternodeList();
LogPrintf("CMasternodeMan::UpdateMasternodeList() - addr: %s\n vin: %s\n", mnb.addr.ToString(), mnb.vin.ToString()); LogPrintf("CMasternodeMan::UpdateMasternodeList() - addr: %s\n vin: %s\n", mnb.addr.ToString(), mnb.vin.ToString());
@ -709,9 +708,11 @@ void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) {
if(pmn == NULL) if(pmn == NULL)
{ {
CMasternode mn(mnb); CMasternode mn(mnb);
Add(mn); if(Add(mn)) {
} else { masternodeSync.AddedMasternodeList();
pmn->UpdateFromNewBroadcast(mnb); }
} else if(pmn->UpdateFromNewBroadcast(mnb)) {
masternodeSync.AddedMasternodeList();
} }
} }
@ -720,7 +721,6 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CMasternodeBroadcast mnb, i
LogPrint("masternode", "CMasternodeMan::CheckMnbAndUpdateMasternodeList - Masternode broadcast, vin: %s\n", mnb.vin.ToString()); LogPrint("masternode", "CMasternodeMan::CheckMnbAndUpdateMasternodeList - Masternode broadcast, vin: %s\n", mnb.vin.ToString());
if(mapSeenMasternodeBroadcast.count(mnb.GetHash())) { //seen if(mapSeenMasternodeBroadcast.count(mnb.GetHash())) { //seen
masternodeSync.AddedMasternodeList();
return true; return true;
} }
mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb)); mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));