diff --git a/src/clientversion.h b/src/clientversion.h index 631f76d245..d738b99da9 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -9,7 +9,7 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 10 #define CLIENT_VERSION_REVISION 15 -#define CLIENT_VERSION_BUILD 19 +#define CLIENT_VERSION_BUILD 21 // Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true diff --git a/src/darksend.cpp b/src/darksend.cpp index 7c3870f516..e66d3fe943 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -30,7 +30,8 @@ std::vector darkSendDenominations; std::vector vecMasternodeAskedFor; /** The current darksends in progress on the network */ std::vector vecDarksendQueue; -// count peers we've requested the list from + + int RequestedMasterNodeList = 0; /* *** BEGIN DARKSEND MAGIC - DARKCOIN ********** @@ -1390,8 +1391,12 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) void CMasternodePayments::Relay(CMasternodePaymentWinner& winner) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + BOOST_FOREACH(CNode* pnode, vNodes){ + if(!pnode->fRelayTxes) + continue; + pnode->PushMessage("mnw", winner); + } } void CMasternodePayments::Sync(CNode* node) diff --git a/src/darksend.h b/src/darksend.h index b59563ce73..2b4c3948b0 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -96,9 +96,9 @@ class CMasternodePaymentWinner { public: int nBlockHeight; - uint64 score; CTxIn vin; std::vector vchSig; + uint64 score; CMasternodePaymentWinner() { nBlockHeight = 0; @@ -106,12 +106,19 @@ public: vin = CTxIn(); } + uint256 GetHash(){ + uint256 n2 = Hash9(BEGIN(nBlockHeight), END(nBlockHeight)); + uint256 n3 = vin.prevout.hash > n2 ? (vin.prevout.hash - n2) : (n2 - vin.prevout.hash); + + return n3; + } + IMPLEMENT_SERIALIZE( READWRITE(nBlockHeight); READWRITE(score); READWRITE(vin); READWRITE(vchSig); - ) + ) }; // diff --git a/src/main.cpp b/src/main.cpp index 34f2a11184..0fe29c47d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,6 +56,8 @@ bool fBenchmark = false; bool fTxIndex = false; unsigned int nCoinCacheSize = 5000; +// keep track of masternode votes I've seen +map mapSeenMasternodeVotes; /** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */ int64 CTransaction::nMinTxFee = 100000; @@ -4210,12 +4212,19 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if(pindexBest == NULL) return false; + uint256 hash = winner.GetHash(); + + if(mapSeenMasternodeVotes.count(hash)) { + if(fDebug) LogPrintf("mnw - SKIPPED %s Height %d bestHeight %d\n", hash.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight); + return true; + } + mapSeenMasternodeVotes.insert(make_pair(hash, 1)); + if(winner.nBlockHeight < pindexBest->nHeight - 10 || winner.nBlockHeight > pindexBest->nHeight+20){ LogPrintf("mnw - winner out of range %s Height %d bestHeight %d\n", winner.vin.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight); return false; } - LogPrintf("mnw - winning vote %s Height %d bestHeight %d\n", winner.vin.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight); if(!masternodePayments.CheckSignature(winner)){ @@ -4224,6 +4233,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return false; } + if(masternodePayments.AddWinningMasternode(winner)){ masternodePayments.Relay(winner); } @@ -4307,11 +4317,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return false; } - if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubkey)) { - LogPrintf("dsee - Got mismatched pubkey and vin\n"); - return false; - } - std::string errorMessage = ""; if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ LogPrintf("dsee - Got bad masternode address signature\n"); diff --git a/src/net.cpp b/src/net.cpp index 9db8e139db..1f4a4b6c55 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1946,6 +1946,9 @@ void RelayDarkSendElectionEntry(const CTxIn vin, const CService addr, const std: LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { + if(!pnode->fRelayTxes) + continue; + pnode->PushMessage("dsee", vin, addr, vchSig, nNow, pubkey, pubkey2, count, current, lastUpdated); } } @@ -1955,6 +1958,9 @@ void RelayDarkSendElectionEntryPing(const CTxIn vin, const std::vectorfRelayTxes) + continue; + pnode->PushMessage("dseep", vin, vchSig, nNow, stop); } } @@ -1965,6 +1971,7 @@ void RelayDarkSendCompletedTransaction(const int sessionID, const bool error, co LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { + pnode->PushMessage("dsc", sessionID, error, errorMessage); } } \ No newline at end of file diff --git a/src/protocol.h b/src/protocol.h index b3367fcaa9..8c6ee9294e 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -142,6 +142,7 @@ enum // Nodes may always request a MSG_FILTERED_BLOCK in a getdata, however, // MSG_FILTERED_BLOCK should not appear in any invs except as a part of getdata. MSG_FILTERED_BLOCK, + MSG_DSEE }; #endif // __INCLUDED_PROTOCOL_H__