From 76e36bfbeac2c3deed321eef91de94777bfdb43b Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Thu, 5 Feb 2015 21:41:17 -0700 Subject: [PATCH] only vote when in the top X nodes --- src/instantx.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/instantx.cpp b/src/instantx.cpp index 4d5e538eb..1202303cf 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -249,10 +249,25 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight) { if(!fMasterNode) return; + int n = GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_INSTANTX_PROTO_VERSION); + + if(n == -1) + { + LogPrintf("InstantX::DoConsensusVote - Unknown Masternode\n"); + return; + } + + if(n > INSTANTX_SIGNATURES_TOTAL) + { + LogPrintf("InstantX::DoConsensusVote - Masternode not in the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n); + return; + } /* nBlockHeight calculated from the transaction is the authoritive source */ + LogPrintf("InstantX::DoConsensusVote - In the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n); + CConsensusVote ctx; ctx.vinMasternode = activeMasternode.vin; ctx.txHash = tx.GetHash();