fixes for sync
This commit is contained in:
parent
dba572ac96
commit
86c869137f
@ -47,6 +47,9 @@ void CMasternodeSync::GetNextAsset()
|
||||
switch(RequestedMasternodeAssets)
|
||||
{
|
||||
case(MASTERNODE_SYNC_INITIAL):
|
||||
lastMasternodeList = 0;
|
||||
lastMasternodeWinner = 0;
|
||||
lastBudgetItem = 0;
|
||||
RequestedMasternodeAssets = MASTERNODE_SYNC_SPORKS;
|
||||
break;
|
||||
case(MASTERNODE_SYNC_SPORKS):
|
||||
@ -76,7 +79,7 @@ void CMasternodeSync::Process()
|
||||
*/
|
||||
if(mnodeman.CountEnabled() == 0) {
|
||||
RequestedMasternodeAssets = MASTERNODE_SYNC_INITIAL;
|
||||
RequestedMasternodeAttempt = 0;
|
||||
GetNextAsset();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -85,7 +88,6 @@ void CMasternodeSync::Process()
|
||||
|
||||
if(fDebug) LogPrintf("CMasternodeSync::Process() - RequestedMasternodeAssets %d c %d\n", RequestedMasternodeAssets, c);
|
||||
|
||||
//request full mn list only if Masternodes.dat was updated quite a long time ago
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_INITIAL) GetNextAsset();
|
||||
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
@ -94,31 +96,33 @@ void CMasternodeSync::Process()
|
||||
LOCK(cs_vNodes);
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
{
|
||||
if (pnode->nVersion >= MIN_POOL_PEER_PROTO_VERSION)
|
||||
{
|
||||
//set to syned
|
||||
if(Params().NetworkID() == CBaseChainParams::REGTEST && c >= 10) {
|
||||
LogPrintf("CMasternodeSync::Process - Sync has finished\n");
|
||||
RequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
|
||||
RequestedMasternodeAttempt = 0;
|
||||
|
||||
//set to synced
|
||||
if(Params().NetworkID() == CBaseChainParams::REGTEST && c >= 10) {
|
||||
LogPrintf("CMasternodeSync::Process - Sync has finished\n");
|
||||
RequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
|
||||
RequestedMasternodeAttempt = 0;
|
||||
}
|
||||
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_SPORKS){
|
||||
if(pnode->HasFulfilledRequest("getspork")) continue;
|
||||
pnode->FulfilledRequest("getspork");
|
||||
|
||||
if(RequestedMasternodeAttempt <= 2){
|
||||
pnode->PushMessage("getsporks"); //get current network sporks
|
||||
if(RequestedMasternodeAttempt == 2) GetNextAsset();
|
||||
RequestedMasternodeAttempt++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_SPORKS){
|
||||
if(pnode->HasFulfilledRequest("getspork")) continue;
|
||||
pnode->FulfilledRequest("getspork");
|
||||
//don't begin syncing until we're at a recent block
|
||||
if(pindexPrev->nHeight < pindexBestHeader->nHeight) return;
|
||||
|
||||
if(RequestedMasternodeAttempt <= 2){
|
||||
pnode->PushMessage("getsporks"); //get current network sporks
|
||||
if(RequestedMasternodeAttempt == 2) GetNextAsset();
|
||||
RequestedMasternodeAttempt++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (pnode->nVersion >= nMasternodeMinProtocol) {
|
||||
|
||||
//don't begin syncing until we're at a recent block
|
||||
if(pindexPrev->nTime + 600 < GetTime()) return;
|
||||
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_LIST){
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_LIST) {
|
||||
if(fDebug) LogPrintf("CMasternodeSync::Process() - lastMasternodeList %lld (GetTime() - MASTERNODE_SYNC_TIMEOUT) %lld\n", lastMasternodeList, GetTime() - MASTERNODE_SYNC_TIMEOUT);
|
||||
if(lastMasternodeList > 0 && lastMasternodeList < GetTime() - MASTERNODE_SYNC_TIMEOUT){ //hasn't received a new item in the last five seconds, so we'll move to the
|
||||
GetNextAsset();
|
||||
return;
|
||||
@ -134,8 +138,10 @@ void CMasternodeSync::Process()
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_MNW){
|
||||
if (pnode->nVersion >= masternodePayments.GetMinMasternodePaymentsProto()) {
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_MNW) {
|
||||
if(lastMasternodeWinner > 0 && lastMasternodeWinner < GetTime() - MASTERNODE_SYNC_TIMEOUT){ //hasn't received a new item in the last five seconds, so we'll move to the
|
||||
GetNextAsset();
|
||||
return;
|
||||
@ -151,6 +157,9 @@ void CMasternodeSync::Process()
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pnode->nVersion >= MIN_BUDGET_PEER_PROTO_VERSION) {
|
||||
|
||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_BUDGET){
|
||||
if(lastBudgetItem > 0 && lastBudgetItem < GetTime() - MASTERNODE_SYNC_TIMEOUT){ //hasn't received a new item in the last five seconds, so we'll move to the
|
||||
|
@ -355,6 +355,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
|
||||
pmn->UpdateFromNewBroadcast((*this));
|
||||
pmn->Check();
|
||||
if(pmn->IsEnabled()) Relay();
|
||||
masternodeSync.AddedMasternodeList();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -618,10 +618,6 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
||||
return;
|
||||
}
|
||||
|
||||
// only ask for missing items after our syncing process is complete --
|
||||
// otherwise we'll think a full sync succeeded when they return a result
|
||||
if(!masternodeSync.IsSynced()) return;
|
||||
|
||||
//search existing Masternode list, if it's known -- don't ask for the mnb
|
||||
CMasternode* pmn = mnodeman.Find(mnp.vin);
|
||||
if(pmn != NULL) return;
|
||||
|
Loading…
Reference in New Issue
Block a user