save nDsqCount in mncache.dat

This commit is contained in:
UdjinM6 2015-03-06 20:25:48 +03:00
parent 9f124d56b6
commit b5414e1c3c
4 changed files with 15 additions and 12 deletions

View File

@ -83,7 +83,7 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand
if(sessionUsers == 0) {
if(pmn->nLastDsq != 0 &&
pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(MIN_POOL_PEER_PROTO_VERSION)/5 > nDsqCount){
pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(MIN_POOL_PEER_PROTO_VERSION)/5 > mnodeman.nDsqCount){
LogPrintf("dsa -- last dsq too recent, must wait. %s \n", pmn->addr.ToString().c_str());
std::string strError = _("Last Darksend was too recent.");
pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, strError);
@ -141,15 +141,15 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand
if(q.vin == dsq.vin) return;
}
if(fDebug) LogPrintf("dsq last %d last2 %d count %d\n", pmn->nLastDsq, pmn->nLastDsq + mnodeman.size()/5, nDsqCount);
if(fDebug) LogPrintf("dsq last %d last2 %d count %d\n", pmn->nLastDsq, pmn->nLastDsq + mnodeman.size()/5, mnodeman.nDsqCount);
//don't allow a few nodes to dominate the queuing process
if(pmn->nLastDsq != 0 &&
pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(MIN_POOL_PEER_PROTO_VERSION)/5 > nDsqCount){
pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(MIN_POOL_PEER_PROTO_VERSION)/5 > mnodeman.nDsqCount){
if(fDebug) LogPrintf("dsq -- Masternode sending too many dsq messages. %s \n", pmn->addr.ToString().c_str());
return;
}
nDsqCount++;
pmn->nLastDsq = nDsqCount;
mnodeman.nDsqCount++;
pmn->nLastDsq = mnodeman.nDsqCount;
pmn->allowFreeTx = true;
if(fDebug) LogPrintf("dsq - new Darksend queue object - %s\n", addr.ToString().c_str());
@ -1783,7 +1783,7 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun, bool ready)
}
if(pmn->nLastDsq != 0 &&
pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(MIN_POOL_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){
pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(MIN_POOL_PEER_PROTO_VERSION)/5 > mnodeman.nDsqCount){
i++;
continue;
}

View File

@ -316,9 +316,6 @@ public:
std::string strMasternodeSharedKey;
bool fResentInputsOutputs;
//incremented whenever a DSQ comes through
int64_t nDsqCount;
CDarksendPool()
{
/* Darksend uses collateral addresses to trust parties entering the pool
@ -329,7 +326,6 @@ public:
unitTest = false;
txCollateral = CTransaction();
minBlockSpacing = 1;
nDsqCount = 0;
lastNewBlock = 0;
strMasternodeSharedKey = "";
fResentInputsOutputs = false;

View File

@ -160,7 +160,9 @@ void DumpMasternodes()
LogPrintf("Masternode dump finished %dms\n", GetTimeMillis() - nStart);
}
CMasternodeMan::CMasternodeMan() {}
CMasternodeMan::CMasternodeMan() {
nDsqCount = 0;
}
bool CMasternodeMan::Add(CMasternode &mn)
{
@ -245,6 +247,7 @@ void CMasternodeMan::Clear()
mAskedUsForMasternodeList.clear();
mWeAskedForMasternodeList.clear();
mWeAskedForMasternodeListEntry.clear();
nDsqCount = 0;
}
int CMasternodeMan::CountEnabled()
@ -765,7 +768,8 @@ std::string CMasternodeMan::ToString() const
info << "Masternodes: " << (int)vMasternodes.size() <<
", peers who asked us for Masternode list: " << (int)mAskedUsForMasternodeList.size() <<
", peers we asked for Masternode list: " << (int)mWeAskedForMasternodeList.size() <<
", entries in Masternode list we asked for: " << (int)mWeAskedForMasternodeListEntry.size();
", entries in Masternode list we asked for: " << (int)mWeAskedForMasternodeListEntry.size() <<
", nDsqCount: " << (int)nDsqCount;
return info.str();
}

View File

@ -63,6 +63,8 @@ private:
std::map<COutPoint, int64_t> mWeAskedForMasternodeListEntry;
public:
// keep track of dsq count to prevent masternodes from gaming darksend queue
int64_t nDsqCount;
IMPLEMENT_SERIALIZE
(
@ -77,6 +79,7 @@ public:
READWRITE(mAskedUsForMasternodeList);
READWRITE(mWeAskedForMasternodeList);
READWRITE(mWeAskedForMasternodeListEntry);
READWRITE(nDsqCount);
}
)