Directly use deterministicMNManager when processing DSTX

This commit is contained in:
Alexander Block 2018-12-17 13:42:28 +01:00
parent ae229e2833
commit b49ef5d712
3 changed files with 15 additions and 5 deletions

View File

@ -127,6 +127,16 @@ void CMasternodeMan::AskForMN(CNode* pnode, const COutPoint& outpoint, CConnman&
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSEG, outpoint));
}
bool CMasternodeMan::IsValidForMixingTxes(const COutPoint& outpoint)
{
LOCK(cs);
CMasternode* pmn = Find(outpoint);
if (!pmn) {
return false;
}
return pmn->IsValidForMixingTxes();
}
bool CMasternodeMan::AllowMixing(const COutPoint &outpoint)
{
LOCK(cs);

View File

@ -137,6 +137,7 @@ public:
void AskForMN(CNode *pnode, const COutPoint& outpoint, CConnman& connman);
bool PoSeBan(const COutPoint &outpoint);
bool IsValidForMixingTxes(const COutPoint &outpoint);
bool AllowMixing(const COutPoint &outpoint);
bool DisallowMixing(const COutPoint &outpoint);

View File

@ -2079,21 +2079,20 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return true; // not an error
}
CMasternode mn;
if(!mnodeman.Get(dstx.masternodeOutpoint, mn)) {
auto dmn = deterministicMNManager->GetListAtChainTip().GetValidMNByCollateral(dstx.masternodeOutpoint);
if(!dmn) {
LogPrint("privatesend", "DSTX -- Can't find masternode %s to verify %s\n", dstx.masternodeOutpoint.ToStringShort(), hashTx.ToString());
return false;
}
if(!mn.IsValidForMixingTxes()) {
if(!mnodeman.IsValidForMixingTxes(dstx.masternodeOutpoint)) {
LogPrint("privatesend", "DSTX -- Masternode %s is sending too many transactions %s\n", dstx.masternodeOutpoint.ToStringShort(), hashTx.ToString());
return true;
// TODO: Not an error? Could it be that someone is relaying old DSTXes
// we have no idea about (e.g we were offline)? How to handle them?
}
if (!dstx.CheckSignature(mn.legacyKeyIDOperator, mn.blsPubKeyOperator)) {
if (!dstx.CheckSignature(dmn->pdmnState->pubKeyOperator)) {
LogPrint("privatesend", "DSTX -- CheckSignature() failed for %s\n", hashTx.ToString());
return false;
}