Improved mnw sync
This commit is contained in:
parent
9e5cd419d0
commit
18fc14e03c
@ -763,6 +763,26 @@ std::string CMasternodePayments::ToString() const
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CMasternodePayments::GetOldestBlock()
|
||||
{
|
||||
LOCK(cs_masternodepayments);
|
||||
|
||||
int nOldestBlock = std::numeric_limits<int>::max();
|
||||
|
||||
std::map<int, CMasternodeBlockPayees>::iterator it = mapMasternodeBlocks.begin();
|
||||
while(it != mapMasternodeBlocks.end()) {
|
||||
if((*it).first < nOldestBlock) {
|
||||
nOldestBlock = (*it).first;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
return nOldestBlock;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CMasternodePayments::GetNewestBlock()
|
||||
{
|
||||
LOCK(cs_masternodepayments);
|
||||
|
@ -243,6 +243,7 @@ public:
|
||||
std::string GetRequiredPaymentsString(int nBlockHeight);
|
||||
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees);
|
||||
std::string ToString() const;
|
||||
int GetOldestBlock();
|
||||
int GetNewestBlock();
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
@ -174,8 +174,14 @@ void CMasternodeSync::Process()
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
if(pindexPrev == NULL) return;
|
||||
|
||||
int nMnCount = mnodeman.CountEnabled()*1.1;
|
||||
int nCountNeeded = (pindexPrev->nHeight - masternodePayments.GetNewestBlock());
|
||||
if(mnodeman.CountEnabled()*1.1 < nCountNeeded) nCountNeeded = mnodeman.CountEnabled()*1.1;
|
||||
int nHaveBlocks = (pindexPrev->nHeight - masternodePayments.GetOldestBlock());
|
||||
if(nHaveBlocks < nMnCount || nCountNeeded > nMnCount) {
|
||||
//We have less blocks than there are masternodes, we need more history
|
||||
// - or our cache is old
|
||||
nCountNeeded = nMnCount;
|
||||
}
|
||||
|
||||
pnode->PushMessage("mnget", nCountNeeded); //sync payees
|
||||
RequestedMasternodeAttempt++;
|
||||
|
@ -453,7 +453,7 @@ Value masternode(const Array& params, bool fHelp)
|
||||
int nLast = 10;
|
||||
|
||||
if (params.size() >= 2){
|
||||
nLast = params[1].get_int();
|
||||
nLast = atoi(params[1].get_str());
|
||||
}
|
||||
|
||||
Object obj;
|
||||
|
Loading…
Reference in New Issue
Block a user