Merge pull request #478 from UdjinM6/v0.12.0.x_sync_added
V0.12.0.x track hashes and update `last...` only twice per hash
This commit is contained in:
commit
0d625c888d
@ -250,6 +250,7 @@ bool CActiveMasternode::Register(CTxIn vin, CService service, CKey keyCollateral
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mnodeman.mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
|
mnodeman.mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
|
||||||
|
masternodeSync.AddedMasternodeList(mnb.GetHash());
|
||||||
|
|
||||||
CMasternode* pmn = mnodeman.Find(vin);
|
CMasternode* pmn = mnodeman.Find(vin);
|
||||||
if(pmn == NULL)
|
if(pmn == NULL)
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -4001,37 +4001,37 @@ bool static AlreadyHave(const CInv& inv)
|
|||||||
return mapSporks.count(inv.hash);
|
return mapSporks.count(inv.hash);
|
||||||
case MSG_MASTERNODE_WINNER:
|
case MSG_MASTERNODE_WINNER:
|
||||||
if(masternodePayments.mapMasternodePayeeVotes.count(inv.hash)) {
|
if(masternodePayments.mapMasternodePayeeVotes.count(inv.hash)) {
|
||||||
masternodeSync.AddedMasternodeWinner();
|
masternodeSync.AddedMasternodeWinner(inv.hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case MSG_BUDGET_VOTE:
|
case MSG_BUDGET_VOTE:
|
||||||
if(budget.mapSeenMasternodeBudgetVotes.count(inv.hash)) {
|
if(budget.mapSeenMasternodeBudgetVotes.count(inv.hash)) {
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(inv.hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case MSG_BUDGET_PROPOSAL:
|
case MSG_BUDGET_PROPOSAL:
|
||||||
if(budget.mapSeenMasternodeBudgetProposals.count(inv.hash)) {
|
if(budget.mapSeenMasternodeBudgetProposals.count(inv.hash)) {
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(inv.hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case MSG_BUDGET_FINALIZED_VOTE:
|
case MSG_BUDGET_FINALIZED_VOTE:
|
||||||
if(budget.mapSeenFinalizedBudgetVotes.count(inv.hash)) {
|
if(budget.mapSeenFinalizedBudgetVotes.count(inv.hash)) {
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(inv.hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case MSG_BUDGET_FINALIZED:
|
case MSG_BUDGET_FINALIZED:
|
||||||
if(budget.mapSeenFinalizedBudgets.count(inv.hash)) {
|
if(budget.mapSeenFinalizedBudgets.count(inv.hash)) {
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(inv.hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case MSG_MASTERNODE_ANNOUNCE:
|
case MSG_MASTERNODE_ANNOUNCE:
|
||||||
if(mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)) {
|
if(mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)) {
|
||||||
masternodeSync.AddedMasternodeList();
|
masternodeSync.AddedMasternodeList(inv.hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -830,7 +830,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
vRecv >> budgetProposalBroadcast;
|
vRecv >> budgetProposalBroadcast;
|
||||||
|
|
||||||
if(mapSeenMasternodeBudgetProposals.count(budgetProposalBroadcast.GetHash())){
|
if(mapSeenMasternodeBudgetProposals.count(budgetProposalBroadcast.GetHash())){
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,7 +849,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
|
|
||||||
CBudgetProposal budgetProposal(budgetProposalBroadcast);
|
CBudgetProposal budgetProposal(budgetProposalBroadcast);
|
||||||
if(AddProposal(budgetProposal)) {budgetProposalBroadcast.Relay();}
|
if(AddProposal(budgetProposal)) {budgetProposalBroadcast.Relay();}
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash());
|
||||||
|
|
||||||
LogPrintf("mprop - new budget - %s\n", budgetProposalBroadcast.GetHash().ToString());
|
LogPrintf("mprop - new budget - %s\n", budgetProposalBroadcast.GetHash().ToString());
|
||||||
|
|
||||||
@ -863,7 +863,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
vote.fValid = true;
|
vote.fValid = true;
|
||||||
|
|
||||||
if(mapSeenMasternodeBudgetVotes.count(vote.GetHash())){
|
if(mapSeenMasternodeBudgetVotes.count(vote.GetHash())){
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(vote.GetHash());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,7 +884,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(UpdateProposal(vote, pfrom, strError)) {
|
if(UpdateProposal(vote, pfrom, strError)) {
|
||||||
vote.Relay();
|
vote.Relay();
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(vote.GetHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrintf("mvote - new budget vote - %s\n", vote.GetHash().ToString());
|
LogPrintf("mvote - new budget vote - %s\n", vote.GetHash().ToString());
|
||||||
@ -895,7 +895,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
vRecv >> finalizedBudgetBroadcast;
|
vRecv >> finalizedBudgetBroadcast;
|
||||||
|
|
||||||
if(mapSeenFinalizedBudgets.count(finalizedBudgetBroadcast.GetHash())){
|
if(mapSeenFinalizedBudgets.count(finalizedBudgetBroadcast.GetHash())){
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -916,7 +916,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
|
|
||||||
CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast);
|
CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast);
|
||||||
if(AddFinalizedBudget(finalizedBudget)) {finalizedBudgetBroadcast.Relay();}
|
if(AddFinalizedBudget(finalizedBudget)) {finalizedBudgetBroadcast.Relay();}
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash());
|
||||||
|
|
||||||
//we might have active votes for this budget that are now valid
|
//we might have active votes for this budget that are now valid
|
||||||
CheckOrphanVotes();
|
CheckOrphanVotes();
|
||||||
@ -928,7 +928,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
vote.fValid = true;
|
vote.fValid = true;
|
||||||
|
|
||||||
if(mapSeenFinalizedBudgetVotes.count(vote.GetHash())){
|
if(mapSeenFinalizedBudgetVotes.count(vote.GetHash())){
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(vote.GetHash());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(UpdateFinalizedBudget(vote, pfrom, strError)) {
|
if(UpdateFinalizedBudget(vote, pfrom, strError)) {
|
||||||
vote.Relay();
|
vote.Relay();
|
||||||
masternodeSync.AddedBudgetItem();
|
masternodeSync.AddedBudgetItem(vote.GetHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint("mnbudget", "fbs - new finalized budget vote - %s\n", vote.GetHash().ToString());
|
LogPrint("mnbudget", "fbs - new finalized budget vote - %s\n", vote.GetHash().ToString());
|
||||||
|
@ -365,7 +365,7 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
|
|||||||
|
|
||||||
if(masternodePayments.mapMasternodePayeeVotes.count(winner.GetHash())){
|
if(masternodePayments.mapMasternodePayeeVotes.count(winner.GetHash())){
|
||||||
LogPrint("mnpayments", "mnw - Already seen - %s bestHeight %d\n", winner.GetHash().ToString().c_str(), chainActive.Tip()->nHeight);
|
LogPrint("mnpayments", "mnw - Already seen - %s bestHeight %d\n", winner.GetHash().ToString().c_str(), chainActive.Tip()->nHeight);
|
||||||
masternodeSync.AddedMasternodeWinner();
|
masternodeSync.AddedMasternodeWinner(winner.GetHash());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +400,7 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
|
|||||||
|
|
||||||
if(masternodePayments.AddWinningMasternode(winner)){
|
if(masternodePayments.AddWinningMasternode(winner)){
|
||||||
winner.Relay();
|
winner.Relay();
|
||||||
masternodeSync.AddedMasternodeWinner();
|
masternodeSync.AddedMasternodeWinner(winner.GetHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -598,6 +598,7 @@ void CMasternodePayments::CleanPaymentList()
|
|||||||
|
|
||||||
if(chainActive.Tip()->nHeight - winner.nBlockHeight > nLimit){
|
if(chainActive.Tip()->nHeight - winner.nBlockHeight > nLimit){
|
||||||
LogPrint("mnpayments", "CMasternodePayments::CleanPaymentList - Removing old Masternode payment - block %d\n", winner.nBlockHeight);
|
LogPrint("mnpayments", "CMasternodePayments::CleanPaymentList - Removing old Masternode payment - block %d\n", winner.nBlockHeight);
|
||||||
|
masternodeSync.mapSeenSyncMNW.erase((*it).first);
|
||||||
mapMasternodePayeeVotes.erase(it++);
|
mapMasternodePayeeVotes.erase(it++);
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
|
@ -75,19 +75,44 @@ void CMasternodeSync::Reset()
|
|||||||
RequestedMasternodeAttempt = 0;
|
RequestedMasternodeAttempt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMasternodeSync::AddedMasternodeList()
|
void CMasternodeSync::AddedMasternodeList(uint256 hash)
|
||||||
{
|
{
|
||||||
|
if(mnodeman.mapSeenMasternodeBroadcast.count(hash)) {
|
||||||
|
if(mapSeenSyncMNB[hash] < 2) {
|
||||||
lastMasternodeList = GetTime();
|
lastMasternodeList = GetTime();
|
||||||
|
mapSeenSyncMNB[hash]++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lastMasternodeList = GetTime();
|
||||||
|
mapSeenSyncMNB.insert(make_pair(hash, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMasternodeSync::AddedMasternodeWinner()
|
void CMasternodeSync::AddedMasternodeWinner(uint256 hash)
|
||||||
{
|
{
|
||||||
|
if(masternodePayments.mapMasternodePayeeVotes.count(hash)) {
|
||||||
|
if(mapSeenSyncMNW[hash] < 2) {
|
||||||
lastMasternodeWinner = GetTime();
|
lastMasternodeWinner = GetTime();
|
||||||
|
mapSeenSyncMNW[hash]++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lastMasternodeWinner = GetTime();
|
||||||
|
mapSeenSyncMNW.insert(make_pair(hash, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMasternodeSync::AddedBudgetItem()
|
void CMasternodeSync::AddedBudgetItem(uint256 hash)
|
||||||
{
|
{
|
||||||
|
if(budget.mapSeenMasternodeBudgetProposals.count(hash) || budget.mapSeenMasternodeBudgetVotes.count(hash) ||
|
||||||
|
budget.mapSeenFinalizedBudgets.count(hash) || budget.mapSeenFinalizedBudgetVotes.count(hash)) {
|
||||||
|
if(mapSeenSyncBudget[hash] < 2) {
|
||||||
lastBudgetItem = GetTime();
|
lastBudgetItem = GetTime();
|
||||||
|
mapSeenSyncBudget[hash]++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lastBudgetItem = GetTime();
|
||||||
|
mapSeenSyncBudget.insert(make_pair(hash, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMasternodeSync::IsBudgetPropEmpty()
|
bool CMasternodeSync::IsBudgetPropEmpty()
|
||||||
@ -141,25 +166,21 @@ void CMasternodeSync::ProcessMessage(CNode* pfrom, std::string& strCommand, CDat
|
|||||||
{
|
{
|
||||||
case(MASTERNODE_SYNC_LIST):
|
case(MASTERNODE_SYNC_LIST):
|
||||||
if(nItemID != RequestedMasternodeAssets) return;
|
if(nItemID != RequestedMasternodeAssets) return;
|
||||||
if(nCount == 0) lastMasternodeList = GetTime();
|
|
||||||
sumMasternodeList += nCount;
|
sumMasternodeList += nCount;
|
||||||
countMasternodeList++;
|
countMasternodeList++;
|
||||||
break;
|
break;
|
||||||
case(MASTERNODE_SYNC_MNW):
|
case(MASTERNODE_SYNC_MNW):
|
||||||
if(nItemID != RequestedMasternodeAssets) return;
|
if(nItemID != RequestedMasternodeAssets) return;
|
||||||
if(nCount == 0) lastMasternodeWinner = GetTime();
|
|
||||||
sumMasternodeWinner += nCount;
|
sumMasternodeWinner += nCount;
|
||||||
countMasternodeWinner++;
|
countMasternodeWinner++;
|
||||||
break;
|
break;
|
||||||
case(MASTERNODE_SYNC_BUDGET_PROP):
|
case(MASTERNODE_SYNC_BUDGET_PROP):
|
||||||
if(RequestedMasternodeAssets != MASTERNODE_SYNC_BUDGET) return;
|
if(RequestedMasternodeAssets != MASTERNODE_SYNC_BUDGET) return;
|
||||||
if(nCount == 0) lastBudgetItem = GetTime();
|
|
||||||
sumBudgetItemProp += nCount;
|
sumBudgetItemProp += nCount;
|
||||||
countBudgetItemProp++;
|
countBudgetItemProp++;
|
||||||
break;
|
break;
|
||||||
case(MASTERNODE_SYNC_BUDGET_FIN):
|
case(MASTERNODE_SYNC_BUDGET_FIN):
|
||||||
if(RequestedMasternodeAssets != MASTERNODE_SYNC_BUDGET) return;
|
if(RequestedMasternodeAssets != MASTERNODE_SYNC_BUDGET) return;
|
||||||
if(nCount == 0) lastBudgetItem = GetTime();
|
|
||||||
sumBudgetItemFin += nCount;
|
sumBudgetItemFin += nCount;
|
||||||
countBudgetItemFin++;
|
countBudgetItemFin++;
|
||||||
break;
|
break;
|
||||||
|
@ -27,6 +27,10 @@ extern CMasternodeSync masternodeSync;
|
|||||||
class CMasternodeSync
|
class CMasternodeSync
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
std::map<uint256, int> mapSeenSyncMNB;
|
||||||
|
std::map<uint256, int> mapSeenSyncMNW;
|
||||||
|
std::map<uint256, int> mapSeenSyncBudget;
|
||||||
|
|
||||||
int64_t lastMasternodeList;
|
int64_t lastMasternodeList;
|
||||||
int64_t lastMasternodeWinner;
|
int64_t lastMasternodeWinner;
|
||||||
int64_t lastBudgetItem;
|
int64_t lastBudgetItem;
|
||||||
@ -50,9 +54,9 @@ public:
|
|||||||
|
|
||||||
CMasternodeSync();
|
CMasternodeSync();
|
||||||
|
|
||||||
void AddedMasternodeList();
|
void AddedMasternodeList(uint256 hash);
|
||||||
void AddedMasternodeWinner();
|
void AddedMasternodeWinner(uint256 hash);
|
||||||
void AddedBudgetItem();
|
void AddedBudgetItem(uint256 hash);
|
||||||
void GetNextAsset();
|
void GetNextAsset();
|
||||||
void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||||||
bool IsBudgetFinEmpty();
|
bool IsBudgetFinEmpty();
|
||||||
|
@ -390,7 +390,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos)
|
|||||||
pmn->UpdateFromNewBroadcast((*this));
|
pmn->UpdateFromNewBroadcast((*this));
|
||||||
pmn->Check();
|
pmn->Check();
|
||||||
if(pmn->IsEnabled()) Relay();
|
if(pmn->IsEnabled()) Relay();
|
||||||
masternodeSync.AddedMasternodeList();
|
masternodeSync.AddedMasternodeList(GetHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -254,6 +254,7 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval)
|
|||||||
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
|
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
|
||||||
while(it3 != mapSeenMasternodeBroadcast.end()){
|
while(it3 != mapSeenMasternodeBroadcast.end()){
|
||||||
if((*it3).second.vin == (*it).vin){
|
if((*it3).second.vin == (*it).vin){
|
||||||
|
masternodeSync.mapSeenSyncMNB.erase((*it3).first);
|
||||||
mapSeenMasternodeBroadcast.erase(it3++);
|
mapSeenMasternodeBroadcast.erase(it3++);
|
||||||
} else {
|
} else {
|
||||||
++it3;
|
++it3;
|
||||||
@ -644,7 +645,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
vRecv >> mnb;
|
vRecv >> mnb;
|
||||||
|
|
||||||
if(mnodeman.mapSeenMasternodeBroadcast.count(mnb.GetHash())) { //seen
|
if(mnodeman.mapSeenMasternodeBroadcast.count(mnb.GetHash())) { //seen
|
||||||
masternodeSync.AddedMasternodeList();
|
masternodeSync.AddedMasternodeList(mnb.GetHash());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mnodeman.mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
|
mnodeman.mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
|
||||||
@ -672,7 +673,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
if(mnb.CheckInputsAndAdd(nDoS)) {
|
if(mnb.CheckInputsAndAdd(nDoS)) {
|
||||||
// use this as a peer
|
// use this as a peer
|
||||||
addrman.Add(CAddress(mnb.addr), pfrom->addr, 2*60*60);
|
addrman.Add(CAddress(mnb.addr), pfrom->addr, 2*60*60);
|
||||||
masternodeSync.AddedMasternodeList();
|
masternodeSync.AddedMasternodeList(mnb.GetHash());
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("mnb - Rejected Masternode entry %s\n", mnb.addr.ToString());
|
LogPrintf("mnb - Rejected Masternode entry %s\n", mnb.addr.ToString());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user