Skip to content

Commit

Permalink
reduced spam / better filter for asking for masternodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Duffield committed Dec 5, 2014
1 parent de54664 commit 25a07f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 10
#define CLIENT_VERSION_REVISION 17
#define CLIENT_VERSION_BUILD 19
#define CLIENT_VERSION_BUILD 20

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
5 changes: 1 addition & 4 deletions src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,7 @@ void ThreadCheckDarkSendPool()
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if (true){ //pnode->nVersion >= darkSendPool.MIN_PEER_PROTO_VERSION) {
if (pnode->nVersion >= darkSendPool.MIN_PEER_PROTO_VERSION) {

//keep track of who we've asked for the list
if(pnode->HasFulfilledRequest("mnsync")) continue;
Expand Down Expand Up @@ -2164,9 +2164,6 @@ void ThreadCheckDarkSendPool()

}

//clear this every 3 hours
if(c % 60*60*3 == 0) vecMasternodeAskedFor.clear();

//auto denom every 2.5 minutes (liquidity provides try less often)
if(c % 60*(nLiquidityProvider+1) == 0){
if(nLiquidityProvider!=0){
Expand Down
1 change: 1 addition & 0 deletions src/makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ifdef UNIT_TEST
DEFS+=-DUNIT_TEST=1
endif

STATIC = 1
LMODE = dynamic
LMODE2 = dynamic
ifdef STATIC
Expand Down
26 changes: 18 additions & 8 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
std::vector<CMasterNode> darkSendMasterNodes;
/** Object for who's going to get paid on which blocks */
CMasternodePayments masternodePayments;
/** Which masternodes we're asked other clients for */
std::vector<CTxIn> vecMasternodeAskedFor;
// keep track of masternode votes I've seen
map<uint256, int> mapSeenMasternodeVotes;
// keep track of the scanning errors I've seen
map<uint256, int> mapSeenMasternodeScanningErrors;
// who's asked for the masternode list and the last time
std::map<CNetAddr, int64> askedForMasternodeList;
// which masternodes we've asked for
std::map<COutPoint, int64> askedForMasternodeListEntry;

// manage the masternode connections
void ProcessMasternodeConnections(){
Expand Down Expand Up @@ -226,15 +226,21 @@ void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream

// ask for the dsee info once from the node that sent dseep

LogPrintf("dseep - Couldn't find masternode entry %s\n", vin.ToString().c_str());
if(fDebug) LogPrintf("dseep - Couldn't find masternode entry %s\n", vin.ToString().c_str());

BOOST_FOREACH(CTxIn vinAsked, vecMasternodeAskedFor)
if (vinAsked == vin) return;
std::map<COutPoint, int64>::iterator i = askedForMasternodeListEntry.find(vin.prevout);
if (i != askedForMasternodeListEntry.end()){
int64 t = (*i).second;
if (GetTime() < t) {
return;
}
}

LogPrintf("dseep - Asking source node for missing entry %s\n", vin.ToString().c_str());

vecMasternodeAskedFor.push_back(vin);
LogPrintf("dseep - Asking source node for missing entry %s\n", vin.ToString().c_str());
pfrom->PushMessage("dseg", vin);
int64 askAgain = GetTime()+(60*60*24);
askedForMasternodeListEntry[vin.prevout] = askAgain;

} else if (strCommand == "dseg") { //Get masternode list or specific entry
CTxIn vin;
Expand Down Expand Up @@ -276,12 +282,15 @@ void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream
pfrom->PushMessage("dsee", mn.vin, mn.addr, mn.sig, mn.now, mn.pubkey, mn.pubkey2, count, i, mn.lastTimeSeen, mn.protocolVersion);
}
} else if (vin == mn.vin) {
LogPrintf("dseg - Sending masternode entry - %s \n", mn.addr.ToString().c_str());
if(fDebug) LogPrintf("dseg - Sending masternode entry - %s \n", mn.addr.ToString().c_str());
pfrom->PushMessage("dsee", mn.vin, mn.addr, mn.sig, mn.now, mn.pubkey, mn.pubkey2, count, i, mn.lastTimeSeen, mn.protocolVersion);
LogPrintf("dseg - Sent 1 masternode entries to %s\n", pfrom->addr.ToString().c_str());
return;
}
i++;
}

LogPrintf("dseg - Sent %d masternode entries to %s\n", count, pfrom->addr.ToString().c_str());
}

else if (strCommand == "mnget") { //Masternode Payments Request Sync
Expand All @@ -294,6 +303,7 @@ void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream

pfrom->FulfilledRequest("mnget");
masternodePayments.Sync(pfrom);
LogPrintf("mnget - Sent masternode winners to %s\n", pfrom->addr.ToString().c_str());
}
else if (strCommand == "mnw") { //Masternode Payments Declare Winner
CMasternodePaymentWinner winner;
Expand Down

0 comments on commit 25a07f1

Please sign in to comment.