limit mnw votes-per-mn
This commit is contained in:
parent
48f9e277f9
commit
85e1280bc3
@ -378,6 +378,11 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
|
||||
return;
|
||||
}
|
||||
|
||||
if(!masternodePayments.CanVote(winner.vinMasternode.prevout, winner.nBlockHeight)){
|
||||
LogPrintf("mnw - masternode already voted - %s\n", winner.vinMasternode.prevout.ToStringShort());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!winner.SignatureValid()){
|
||||
LogPrintf("mnw - invalid signature\n");
|
||||
Misbehaving(pfrom->GetId(), 100);
|
||||
@ -388,7 +393,7 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
|
||||
ExtractDestination(winner.payee, address1);
|
||||
CBitcoinAddress address2(address1);
|
||||
|
||||
if(fDebug) LogPrintf("mnw - winning vote - Addr %s Height %d bestHeight %d\n", address2.ToString().c_str(), winner.nBlockHeight, chainActive.Tip()->nHeight);
|
||||
if(fDebug) LogPrintf("mnw - winning vote - Addr %s Height %d bestHeight %d - %s\n", address2.ToString().c_str(), winner.nBlockHeight, chainActive.Tip()->nHeight, winner.vinMasternode.prevout.ToStringShort());
|
||||
|
||||
if(masternodePayments.AddWinningMasternode(winner)){
|
||||
winner.Relay();
|
||||
|
@ -181,6 +181,7 @@ public:
|
||||
payee = payeeIn;
|
||||
}
|
||||
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
@ -216,6 +217,7 @@ private:
|
||||
public:
|
||||
std::map<uint256, CMasternodePaymentWinner> mapMasternodePayeeVotes;
|
||||
std::map<int, CMasternodeBlockPayees> mapMasternodeBlocks;
|
||||
std::map<uint256, int> mapMasternodesLastVote; //prevout.hash + prevout.n, nBlockHeight
|
||||
|
||||
CMasternodePayments() {
|
||||
nSyncedFromPeer = 0;
|
||||
@ -238,6 +240,18 @@ public:
|
||||
bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight);
|
||||
bool IsScheduled(CMasternode& mn, int nNotBlockHeight);
|
||||
|
||||
bool CanVote(COutPoint outMasternode, int nBlockHeight) {
|
||||
if(mapMasternodesLastVote.count(outMasternode.hash + outMasternode.n)) {
|
||||
if(mapMasternodesLastVote[outMasternode.hash + outMasternode.n] == nBlockHeight) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//record this masternode voted
|
||||
mapMasternodesLastVote[outMasternode.hash + outMasternode.n] = nBlockHeight;
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetMinMasternodePaymentsProto();
|
||||
void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||||
std::string GetRequiredPaymentsString(int nBlockHeight);
|
||||
|
Loading…
Reference in New Issue
Block a user