Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 0 additions & 4 deletions src/darksend.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,6 @@ class CDarksendPool
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
Expand All @@ -329,7 +326,6 @@ class CDarksendPool
unitTest = false;
txCollateral = CTransaction();
minBlockSpacing = 1;
nDsqCount = 0;
lastNewBlock = 0;
strMasternodeSharedKey = "";
fResentInputsOutputs = false;
Expand Down
8 changes: 6 additions & 2 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -245,6 +247,7 @@ void CMasternodeMan::Clear()
mAskedUsForMasternodeList.clear();
mWeAskedForMasternodeList.clear();
mWeAskedForMasternodeListEntry.clear();
nDsqCount = 0;
}

int CMasternodeMan::CountEnabled()
Expand Down Expand Up @@ -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();
}
3 changes: 3 additions & 0 deletions src/masternodeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class CMasternodeMan
std::map<COutPoint, int64_t> mWeAskedForMasternodeListEntry;

public:
// keep track of dsq count to prevent masternodes from gaming darksend queue
int64_t nDsqCount;

IMPLEMENT_SERIALIZE
(
Expand All @@ -77,6 +79,7 @@ class CMasternodeMan
READWRITE(mAskedUsForMasternodeList);
READWRITE(mWeAskedForMasternodeList);
READWRITE(mWeAskedForMasternodeListEntry);
READWRITE(nDsqCount);
}
)

Expand Down