Remove deprecated masternode sync members
This commit is contained in:
parent
84ac8de59d
commit
08f8300985
@ -298,7 +298,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
|
||||
|
||||
if(mapMasternodePayeeVotes.count(winner.GetHash())) {
|
||||
LogPrint("mnpayments", "MNWINNER -- Already seen: hash=%s, nHeight=%d\n", winner.GetHash().ToString(), pCurrentBlockIndex->nHeight);
|
||||
masternodeSync.AddedMasternodeWinner(winner.GetHash());
|
||||
masternodeSync.AddedMasternodeWinner();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
|
||||
|
||||
if(AddWinningMasternode(winner)){
|
||||
winner.Relay();
|
||||
masternodeSync.AddedMasternodeWinner(winner.GetHash());
|
||||
masternodeSync.AddedMasternodeWinner();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -531,14 +531,13 @@ void CMasternodePayments::CheckAndRemove()
|
||||
|
||||
if(pCurrentBlockIndex->nHeight - winner.nBlockHeight > nLimit){
|
||||
LogPrint("mnpayments", "CMasternodePayments::CleanPaymentList - Removing old Masternode payment - block %d\n", winner.nBlockHeight);
|
||||
masternodeSync.mapSeenSyncMNW.erase((*it).first);
|
||||
mapMasternodePayeeVotes.erase(it++);
|
||||
mapMasternodeBlocks.erase(winner.nBlockHeight);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
LogPrintf("CMasternodePayments::CleanPaymentList() - %s mapSeenSyncMNW %lld\n", ToString(), masternodeSync.mapSeenSyncMNW.size());
|
||||
LogPrintf("CMasternodePayments::CleanPaymentList() - %s\n", ToString());
|
||||
}
|
||||
|
||||
bool CMasternodePaymentWinner::IsValid(CNode* pnode, int nValidationHeight, std::string& strError)
|
||||
|
@ -55,39 +55,6 @@ void CMasternodeSync::Reset()
|
||||
nTimeLastBudgetItem = GetTime();
|
||||
nTimeLastFailure = 0;
|
||||
nCountFailures = 0;
|
||||
nSumMasternodeList = 0;
|
||||
nSumMasternodeWinner = 0;
|
||||
nSumBudgetItemProp = 0;
|
||||
nSumBudgetItemFin = 0;
|
||||
nCountMasternodeList = 0;
|
||||
nCountMasternodeWinner = 0;
|
||||
nCountBudgetItemProp = 0;
|
||||
nCountBudgetItemFin = 0;
|
||||
mapSeenSyncMNB.clear();
|
||||
mapSeenSyncMNW.clear();
|
||||
mapSeenSyncBudget.clear();
|
||||
}
|
||||
|
||||
void CMasternodeSync::AddedMasternodeList(uint256 hash)
|
||||
{
|
||||
if(mnodeman.mapSeenMasternodeBroadcast.count(hash)) {
|
||||
nTimeLastMasternodeList = GetTime();
|
||||
mapSeenSyncMNB[hash]++;
|
||||
} else {
|
||||
nTimeLastMasternodeList = GetTime();
|
||||
mapSeenSyncMNB.insert(std::make_pair(hash, 1));
|
||||
}
|
||||
}
|
||||
|
||||
void CMasternodeSync::AddedMasternodeWinner(uint256 hash)
|
||||
{
|
||||
if(mnpayments.mapMasternodePayeeVotes.count(hash)) {
|
||||
nTimeLastMasternodeWinner = GetTime();
|
||||
mapSeenSyncMNW[hash]++;
|
||||
} else {
|
||||
nTimeLastMasternodeWinner = GetTime();
|
||||
mapSeenSyncMNW.insert(std::make_pair(hash, 1));
|
||||
}
|
||||
}
|
||||
|
||||
std::string CMasternodeSync::GetAssetName()
|
||||
@ -157,38 +124,15 @@ std::string CMasternodeSync::GetSyncStatus()
|
||||
void CMasternodeSync::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
|
||||
{
|
||||
if (strCommand == NetMsgType::SYNCSTATUSCOUNT) { //Sync status count
|
||||
int nItemID;
|
||||
int nCount;
|
||||
vRecv >> nItemID >> nCount;
|
||||
|
||||
//do not care about stats if sync process finished or failed
|
||||
if(IsSynced() || IsFailed()) return;
|
||||
|
||||
switch(nItemID)
|
||||
{
|
||||
case(MASTERNODE_SYNC_LIST):
|
||||
if(nItemID != nRequestedMasternodeAssets) return;
|
||||
nSumMasternodeList += nCount;
|
||||
nCountMasternodeList++;
|
||||
break;
|
||||
case(MASTERNODE_SYNC_MNW):
|
||||
if(nItemID != nRequestedMasternodeAssets) return;
|
||||
nSumMasternodeWinner += nCount;
|
||||
nCountMasternodeWinner++;
|
||||
break;
|
||||
case(MASTERNODE_SYNC_GOVOBJ):
|
||||
if(nRequestedMasternodeAssets != MASTERNODE_SYNC_GOVERNANCE) return;
|
||||
nSumBudgetItemProp += nCount;
|
||||
nCountBudgetItemProp++;
|
||||
break;
|
||||
case(MASTERNODE_SYNC_GOVERNANCE_FIN):
|
||||
if(nRequestedMasternodeAssets != MASTERNODE_SYNC_GOVERNANCE) return;
|
||||
nSumBudgetItemFin += nCount;
|
||||
nCountBudgetItemFin++;
|
||||
break;
|
||||
}
|
||||
int nItemID;
|
||||
int nCount;
|
||||
vRecv >> nItemID >> nCount;
|
||||
|
||||
LogPrintf("CMasternodeSync::ProcessMessage -- SYNCSTATUSCOUNT -- got inventory count: nItemID=%d nCount=%d\n", nItemID, nCount);
|
||||
LogPrintf("CMasternodeSync::ProcessMessage -- SYNCSTATUSCOUNT -- got inventory count: nItemID=%d nCount=%d peer=%d\n", nItemID, nCount, pfrom->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,18 +50,6 @@ private:
|
||||
// How many times we failed
|
||||
int nCountFailures;
|
||||
|
||||
// Sum of all data counts
|
||||
int nSumMasternodeList;
|
||||
int nSumMasternodeWinner;
|
||||
int nSumBudgetItemProp;
|
||||
int nSumBudgetItemFin;
|
||||
|
||||
// Number of peers that reported data counts
|
||||
int nCountMasternodeList;
|
||||
int nCountMasternodeWinner;
|
||||
int nCountBudgetItemProp;
|
||||
int nCountBudgetItemFin;
|
||||
|
||||
// Keep track of current block index
|
||||
const CBlockIndex *pCurrentBlockIndex;
|
||||
|
||||
@ -69,14 +57,10 @@ private:
|
||||
void ClearFulfilledRequest();
|
||||
|
||||
public:
|
||||
std::map<uint256, int> mapSeenSyncMNB;
|
||||
std::map<uint256, int> mapSeenSyncMNW;
|
||||
std::map<uint256, int> mapSeenSyncBudget;
|
||||
|
||||
CMasternodeSync() { Reset(); }
|
||||
|
||||
void AddedMasternodeList(uint256 hash);
|
||||
void AddedMasternodeWinner(uint256 hash);
|
||||
void AddedMasternodeList() { nTimeLastMasternodeList = GetTime(); }
|
||||
void AddedMasternodeWinner() { nTimeLastMasternodeWinner = GetTime(); }
|
||||
void AddedBudgetItem(uint256 hash);
|
||||
|
||||
bool IsFailed() { return nRequestedMasternodeAssets == MASTERNODE_SYNC_FAILED; }
|
||||
|
@ -474,7 +474,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
|
||||
Relay();
|
||||
}
|
||||
}
|
||||
masternodeSync.AddedMasternodeList(GetHash());
|
||||
masternodeSync.AddedMasternodeList();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -506,7 +506,6 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDos)
|
||||
LogPrintf("CMasternodeBroadcast::CheckInputsAndAdd -- Input must have at least %d confirmations\n", Params().GetConsensus().nMasternodeMinimumConfirmations);
|
||||
// maybe we miss few blocks, let this mnb to be checked again later
|
||||
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
|
||||
masternodeSync.mapSeenSyncMNB.erase(GetHash());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -521,7 +520,6 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDos)
|
||||
if(!lockMain) {
|
||||
// not mnb fault, let it to be checked again later
|
||||
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
|
||||
masternodeSync.mapSeenSyncMNB.erase(GetHash());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,6 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval)
|
||||
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
|
||||
while(it3 != mapSeenMasternodeBroadcast.end()){
|
||||
if((*it3).second.vin == (*it).vin){
|
||||
masternodeSync.mapSeenSyncMNB.erase((*it3).first);
|
||||
mapSeenMasternodeBroadcast.erase(it3++);
|
||||
} else {
|
||||
++it3;
|
||||
@ -172,7 +171,6 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval)
|
||||
while(it3 != mapSeenMasternodeBroadcast.end()){
|
||||
if((*it3).second.lastPing.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){
|
||||
LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode broadcast %s\n", (*it3).second.GetHash().ToString());
|
||||
masternodeSync.mapSeenSyncMNB.erase((*it3).second.GetHash());
|
||||
mapSeenMasternodeBroadcast.erase(it3++);
|
||||
} else {
|
||||
++it3;
|
||||
@ -729,7 +727,7 @@ int CMasternodeMan::GetEstimatedMasternodes(int nBlock)
|
||||
void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) {
|
||||
mapSeenMasternodePing.insert(make_pair(mnb.lastPing.GetHash(), mnb.lastPing));
|
||||
mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
|
||||
masternodeSync.AddedMasternodeList(mnb.GetHash());
|
||||
masternodeSync.AddedMasternodeList();
|
||||
|
||||
LogPrintf("CMasternodeMan::UpdateMasternodeList() - addr: %s\n vin: %s\n", mnb.addr.ToString(), mnb.vin.ToString());
|
||||
|
||||
@ -748,7 +746,7 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CMasternodeBroadcast mnb, i
|
||||
LogPrint("masternode", "CMasternodeMan::CheckMnbAndUpdateMasternodeList - Masternode broadcast, vin: %s\n", mnb.vin.ToString());
|
||||
|
||||
if(mapSeenMasternodeBroadcast.count(mnb.GetHash())) { //seen
|
||||
masternodeSync.AddedMasternodeList(mnb.GetHash());
|
||||
masternodeSync.AddedMasternodeList();
|
||||
return true;
|
||||
}
|
||||
mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
|
||||
@ -763,7 +761,7 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CMasternodeBroadcast mnb, i
|
||||
// make sure it's still unspent
|
||||
// - this is checked later by .check() in many places and by ThreadCheckDarkSendPool()
|
||||
if(mnb.CheckInputsAndAdd(nDos)) {
|
||||
masternodeSync.AddedMasternodeList(mnb.GetHash());
|
||||
masternodeSync.AddedMasternodeList();
|
||||
} else {
|
||||
LogPrintf("CMasternodeMan::CheckMnbAndUpdateMasternodeList - Rejected Masternode entry %s\n", mnb.addr.ToString());
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user