added bloom filters for dsee/dseep broadcasts, moved expensive dsee search, masternode vote caching

This commit is contained in:
Evan Duffield 2014-11-05 16:55:12 -07:00
parent 30219348d7
commit 7fa8431262
6 changed files with 36 additions and 11 deletions

View File

@ -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

View File

@ -30,7 +30,8 @@ std::vector<int64> darkSendDenominations;
std::vector<CTxIn> vecMasternodeAskedFor;
/** The current darksends in progress on the network */
std::vector<CDarksendQueue> 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)

View File

@ -96,9 +96,9 @@ class CMasternodePaymentWinner
{
public:
int nBlockHeight;
uint64 score;
CTxIn vin;
std::vector<unsigned char> 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);
)
)
};
//

View File

@ -56,6 +56,8 @@ bool fBenchmark = false;
bool fTxIndex = false;
unsigned int nCoinCacheSize = 5000;
// keep track of masternode votes I've seen
map<uint256, int> 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");

View File

@ -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::vector<unsigned
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if(!pnode->fRelayTxes)
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);
}
}

View File

@ -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__