From 631e4b505f4d2e4d2ec5571667ac744b5ab48da2 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Tue, 7 Apr 2015 12:59:30 -0700 Subject: [PATCH] fixed vote-many --- configure.ac | 2 +- src/clientversion.h | 2 +- src/masternodeman.cpp | 14 ++++++++++++++ src/masternodeman.h | 1 + src/rpcdarksend.cpp | 39 +++++++++++++++++++++++++++++---------- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 6e5a3b261..52eafbbb2 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 11) define(_CLIENT_VERSION_REVISION, 2) -define(_CLIENT_VERSION_BUILD, 18) +define(_CLIENT_VERSION_BUILD, 19) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2015) AC_INIT([Dash Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@dashpay.io],[dash]) diff --git a/src/clientversion.h b/src/clientversion.h index d247a32e4..f02234e53 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -12,7 +12,7 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 11 #define CLIENT_VERSION_REVISION 2 -#define CLIENT_VERSION_BUILD 18 +#define CLIENT_VERSION_BUILD 19 diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index bfb578836..afaed60a1 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -333,6 +333,20 @@ CMasternode *CMasternodeMan::Find(const CTxIn &vin) return NULL; } + +CMasternode *CMasternodeMan::Find(const CPubKey &pubKeyMasternode) +{ + LOCK(cs); + + BOOST_FOREACH(CMasternode& mn, vMasternodes) + { + if(mn.pubkey2 == pubKeyMasternode) + return &mn; + } + return NULL; +} + + CMasternode* CMasternodeMan::FindOldestNotInVec(const std::vector &vVins, int nMinimumAge, int nMinimumActiveSeconds) { LOCK(cs); diff --git a/src/masternodeman.h b/src/masternodeman.h index d4ba67609..31ad4cbb8 100644 --- a/src/masternodeman.h +++ b/src/masternodeman.h @@ -108,6 +108,7 @@ public: /// Find an entry CMasternode* Find(const CTxIn& vin); + CMasternode* Find(const CPubKey& pubKeyMasternode); /// Find an entry thta do not match every entry provided vector CMasternode* FindOldestNotInVec(const std::vector &vVins, int nMinimumAge, int nMinimumActiveSeconds); diff --git a/src/rpcdarksend.cpp b/src/rpcdarksend.cpp index ba9ec66ce..0dfd54da1 100644 --- a/src/rpcdarksend.cpp +++ b/src/rpcdarksend.cpp @@ -583,6 +583,9 @@ Value masternode(const Array& params, bool fHelp) if(vote == "nay") nVote = -1; + int success = 0; + int failed = 0; + Object resultObj; BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { @@ -596,27 +599,43 @@ Value masternode(const Array& params, bool fHelp) CPubKey pubKeyMasternode; CKey keyMasternode; - if(!activeMasternode.GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress, mne.getTxHash(), mne.getOutputIndex())) { - return("could not allocate vin"); + if(!darkSendSigner.SetKey(mne.getPrivKey(), errorMessage, keyMasternode, pubKeyMasternode)){ + printf(" Error upon calling SetKey for %s\n", mne.getAlias().c_str()); + failed++; + continue; + } + + CMasternode* pmn = mnodeman.Find(pubKeyMasternode); + if(pmn == NULL) + { + printf("Can't find masternode by pubkey for %s\n", mne.getAlias().c_str()); + failed++; + continue; } - std::string strMessage = vin.ToString() + boost::lexical_cast(nVote); + std::string strMessage = pmn->vin.ToString() + boost::lexical_cast(nVote); - if(!darkSendSigner.SetKey(mne.getPrivKey(), errorMessage, keyMasternode, pubKeyMasternode)) - return(" Error upon calling SetKey"); + if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, keyMasternode)){ + printf(" Error upon calling SignMessage for %s\n", mne.getAlias().c_str()); + failed++; + continue; + } - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, keyMasternode)) - return(" Error upon calling SignMessage"); + if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchMasterNodeSignature, strMessage, errorMessage)){ + printf(" Error upon calling VerifyMessage for %s\n", mne.getAlias().c_str()); + failed++; + continue; + } - if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchMasterNodeSignature, strMessage, errorMessage)) - return(" Error upon calling VerifyMessage"); + success++; //send to all peers LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) pnode->PushMessage("mvote", vin, vchMasterNodeSignature, nVote); - } + + return("Voted successfully " + boost::lexical_cast(success) + " time(s) and failed " + boost::lexical_cast(failed) + " time(s)."); } if(strCommand == "vote")