dsq fixes: (#1128)
- make sure dsq is not too much in the future - do not process seen dsq - do not alter nTime for dsq localy, use memory only fTried instead
This commit is contained in:
parent
eca1e8a4f1
commit
f2d2b25130
@ -98,9 +98,17 @@ void CDarksendPool::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataS
|
|||||||
CDarksendQueue dsq;
|
CDarksendQueue dsq;
|
||||||
vRecv >> dsq;
|
vRecv >> dsq;
|
||||||
|
|
||||||
|
// process every dsq only once
|
||||||
|
BOOST_FOREACH(CDarksendQueue q, vecDarksendQueue) {
|
||||||
|
if(q == dsq) {
|
||||||
|
// LogPrint("privatesend", "DSQUEUE -- %s seen\n", dsq.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LogPrint("privatesend", "DSQUEUE -- %s new\n", dsq.ToString());
|
LogPrint("privatesend", "DSQUEUE -- %s new\n", dsq.ToString());
|
||||||
|
|
||||||
if(dsq.IsExpired()) return;
|
if(dsq.IsExpired() || dsq.nTime > GetTime() + PRIVATESEND_QUEUE_TIMEOUT) return;
|
||||||
|
|
||||||
CMasternode* pmn = mnodeman.Find(dsq.vin);
|
CMasternode* pmn = mnodeman.Find(dsq.vin);
|
||||||
if(pmn == NULL) return;
|
if(pmn == NULL) return;
|
||||||
@ -124,8 +132,13 @@ void CDarksendPool::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataS
|
|||||||
SubmitDenominate();
|
SubmitDenominate();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BOOST_FOREACH(CDarksendQueue q, vecDarksendQueue)
|
BOOST_FOREACH(CDarksendQueue q, vecDarksendQueue) {
|
||||||
if(q.vin == dsq.vin) return;
|
if(q.vin == dsq.vin) {
|
||||||
|
// no way same mn can send another "not yet ready" dsq this soon
|
||||||
|
LogPrint("privatesend", "DSQUEUE -- Masternode %s is sending WAY too many dsq messages\n", pmn->addr.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int nThreshold = pmn->nLastDsq + mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION)/5;
|
int nThreshold = pmn->nLastDsq + mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION)/5;
|
||||||
LogPrint("privatesend", "DSQUEUE -- nLastDsq: %d threshold: %d nDsqCount: %d\n", pmn->nLastDsq, nThreshold, mnodeman.nDsqCount);
|
LogPrint("privatesend", "DSQUEUE -- nLastDsq: %d threshold: %d nDsqCount: %d\n", pmn->nLastDsq, nThreshold, mnodeman.nDsqCount);
|
||||||
@ -139,9 +152,11 @@ void CDarksendPool::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataS
|
|||||||
pmn->fAllowMixingTx = true;
|
pmn->fAllowMixingTx = true;
|
||||||
|
|
||||||
LogPrint("privatesend", "DSQUEUE -- new PrivateSend queue (%s) from masternode %s\n", dsq.ToString(), pmn->addr.ToString());
|
LogPrint("privatesend", "DSQUEUE -- new PrivateSend queue (%s) from masternode %s\n", dsq.ToString(), pmn->addr.ToString());
|
||||||
|
if(pSubmittedToMasternode && pSubmittedToMasternode->vin.prevout == dsq.vin.prevout) {
|
||||||
|
dsq.fTried = true;
|
||||||
|
}
|
||||||
vecDarksendQueue.push_back(dsq);
|
vecDarksendQueue.push_back(dsq);
|
||||||
dsq.Relay();
|
dsq.Relay();
|
||||||
dsq.nTime = GetTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(strCommand == NetMsgType::DSVIN) {
|
} else if(strCommand == NetMsgType::DSVIN) {
|
||||||
@ -1536,7 +1551,9 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
|
|||||||
|
|
||||||
// Look through the queues and see if anything matches
|
// Look through the queues and see if anything matches
|
||||||
BOOST_FOREACH(CDarksendQueue& dsq, vecDarksendQueue) {
|
BOOST_FOREACH(CDarksendQueue& dsq, vecDarksendQueue) {
|
||||||
if(dsq.nTime == 0) continue;
|
// only try each queue once
|
||||||
|
if(dsq.fTried) continue;
|
||||||
|
dsq.fTried = true;
|
||||||
if(dsq.IsExpired()) continue;
|
if(dsq.IsExpired()) continue;
|
||||||
|
|
||||||
CMasternode* pmn = mnodeman.Find(dsq.vin);
|
CMasternode* pmn = mnodeman.Find(dsq.vin);
|
||||||
@ -1578,12 +1595,10 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
|
|||||||
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected (from queue), sending DSACCEPT: nSessionDenom: %d (%s), addr=%s\n",
|
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected (from queue), sending DSACCEPT: nSessionDenom: %d (%s), addr=%s\n",
|
||||||
nSessionDenom, GetDenominationsToString(nSessionDenom), pnode->addr.ToString());
|
nSessionDenom, GetDenominationsToString(nSessionDenom), pnode->addr.ToString());
|
||||||
strAutoDenomResult = _("Mixing in progress...");
|
strAutoDenomResult = _("Mixing in progress...");
|
||||||
dsq.nTime = 0; //remove node
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("CDarksendPool::DoAutomaticDenominating -- can't connect, addr=%s\n", pmn->addr.ToString());
|
LogPrintf("CDarksendPool::DoAutomaticDenominating -- can't connect, addr=%s\n", pmn->addr.ToString());
|
||||||
strAutoDenomResult = _("Error connecting to Masternode.");
|
strAutoDenomResult = _("Error connecting to Masternode.");
|
||||||
dsq.nTime = 0; //remove node
|
|
||||||
pmn->IncreasePoSeBanScore();
|
pmn->IncreasePoSeBanScore();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -144,13 +144,16 @@ public:
|
|||||||
int64_t nTime;
|
int64_t nTime;
|
||||||
bool fReady; //ready for submit
|
bool fReady; //ready for submit
|
||||||
std::vector<unsigned char> vchSig;
|
std::vector<unsigned char> vchSig;
|
||||||
|
// memory only
|
||||||
|
bool fTried;
|
||||||
|
|
||||||
CDarksendQueue() :
|
CDarksendQueue() :
|
||||||
nDenom(0),
|
nDenom(0),
|
||||||
vin(CTxIn()),
|
vin(CTxIn()),
|
||||||
nTime(0),
|
nTime(0),
|
||||||
fReady(false),
|
fReady(false),
|
||||||
vchSig(std::vector<unsigned char>())
|
vchSig(std::vector<unsigned char>()),
|
||||||
|
fTried(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CDarksendQueue(int nDenom, CTxIn vin, int64_t nTime, bool fReady) :
|
CDarksendQueue(int nDenom, CTxIn vin, int64_t nTime, bool fReady) :
|
||||||
@ -158,7 +161,8 @@ public:
|
|||||||
vin(vin),
|
vin(vin),
|
||||||
nTime(nTime),
|
nTime(nTime),
|
||||||
fReady(fReady),
|
fReady(fReady),
|
||||||
vchSig(std::vector<unsigned char>())
|
vchSig(std::vector<unsigned char>()),
|
||||||
|
fTried(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
ADD_SERIALIZE_METHODS;
|
||||||
@ -190,8 +194,13 @@ public:
|
|||||||
|
|
||||||
std::string ToString()
|
std::string ToString()
|
||||||
{
|
{
|
||||||
return strprintf("nDenom=%d, nTime=%lld, fReady=%s, masternode=%s",
|
return strprintf("nDenom=%d, nTime=%lld, fReady=%s, fTried=%s, masternode=%s",
|
||||||
nDenom, nTime, fReady ? "true" : "false", vin.prevout.ToStringShort());
|
nDenom, nTime, fReady ? "true" : "false", fTried ? "true" : "false", vin.prevout.ToStringShort());
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator==(const CDarksendQueue& a, const CDarksendQueue& b)
|
||||||
|
{
|
||||||
|
return a.nDenom == b.nDenom && a.vin.prevout == b.vin.prevout && a.nTime == b.nTime && a.fReady == b.fReady;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user