Masternode inv messages / save seen in mncache
This commit is contained in:
parent
43101ebeca
commit
c0a5dfba61
@ -171,7 +171,7 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pmn->lastPing = mnp;
|
pmn->lastPing = mnp;
|
||||||
mapSeenMasternodePing[mnp.GetHash()] = mnp;
|
mnodeman.mapSeenMasternodePing[mnp.GetHash()] = mnp;
|
||||||
mnp.Relay();
|
mnp.Relay();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -244,7 +244,7 @@ bool CActiveMasternode::Register(CTxIn vin, CService service, CKey keyCollateral
|
|||||||
LogPrintf("CActiveMasternode::Register() - %s\n", errorMessage);
|
LogPrintf("CActiveMasternode::Register() - %s\n", errorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mapSeenMasternodePing[mnp.GetHash()] = mnp;
|
mnodeman.mapSeenMasternodePing[mnp.GetHash()] = mnp;
|
||||||
|
|
||||||
LogPrintf("CActiveMasternode::Register() - Adding to Masternode list\n service: %s\n vin: %s\n", service.ToString(), vin.ToString());
|
LogPrintf("CActiveMasternode::Register() - Adding to Masternode list\n service: %s\n vin: %s\n", service.ToString(), vin.ToString());
|
||||||
mnb = CMasternodeBroadcast(service, vin, pubKeyCollateralAddress, pubKeyMasternode, PROTOCOL_VERSION);
|
mnb = CMasternodeBroadcast(service, vin, pubKeyCollateralAddress, pubKeyMasternode, PROTOCOL_VERSION);
|
||||||
@ -254,7 +254,7 @@ bool CActiveMasternode::Register(CTxIn vin, CService service, CKey keyCollateral
|
|||||||
LogPrintf("CActiveMasternode::Register() - %s\n", errorMessage);
|
LogPrintf("CActiveMasternode::Register() - %s\n", errorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mapSeenMasternodeBroadcast[mnb.GetHash()] = mnb;
|
mnodeman.mapSeenMasternodeBroadcast[mnb.GetHash()] = mnb;
|
||||||
|
|
||||||
CMasternode* pmn = mnodeman.Find(vin);
|
CMasternode* pmn = mnodeman.Find(vin);
|
||||||
if(pmn == NULL)
|
if(pmn == NULL)
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -4016,13 +4016,13 @@ bool static AlreadyHave(const CInv& inv)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case MSG_MASTERNODE_ANNOUNCE:
|
case MSG_MASTERNODE_ANNOUNCE:
|
||||||
if(mapSeenMasternodeBroadcast.count(inv.hash)) {
|
if(mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)) {
|
||||||
masternodeSync.AddedMasternodeList();
|
masternodeSync.AddedMasternodeList();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case MSG_MASTERNODE_PING:
|
case MSG_MASTERNODE_PING:
|
||||||
return mapSeenMasternodePing.count(inv.hash);
|
return mnodeman.mapSeenMasternodePing.count(inv.hash);
|
||||||
}
|
}
|
||||||
// Don't know what it is, just say we already got one
|
// Don't know what it is, just say we already got one
|
||||||
return true;
|
return true;
|
||||||
@ -4223,20 +4223,20 @@ void static ProcessGetData(CNode* pfrom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pushed && inv.type == MSG_MASTERNODE_ANNOUNCE) {
|
if (!pushed && inv.type == MSG_MASTERNODE_ANNOUNCE) {
|
||||||
if(mapSeenMasternodeBroadcast.count(inv.hash)){
|
if(mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)){
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
ss.reserve(1000);
|
ss.reserve(1000);
|
||||||
ss << mapSeenMasternodeBroadcast[inv.hash];
|
ss << mnodeman.mapSeenMasternodeBroadcast[inv.hash];
|
||||||
pfrom->PushMessage("mnb", ss);
|
pfrom->PushMessage("mnb", ss);
|
||||||
pushed = true;
|
pushed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pushed && inv.type == MSG_MASTERNODE_PING) {
|
if (!pushed && inv.type == MSG_MASTERNODE_PING) {
|
||||||
if(mapSeenMasternodePing.count(inv.hash)){
|
if(mnodeman.mapSeenMasternodePing.count(inv.hash)){
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
ss.reserve(1000);
|
ss.reserve(1000);
|
||||||
ss << mapSeenMasternodePing[inv.hash];
|
ss << mnodeman.mapSeenMasternodePing[inv.hash];
|
||||||
pfrom->PushMessage("mnp", ss);
|
pfrom->PushMessage("mnp", ss);
|
||||||
pushed = true;
|
pushed = true;
|
||||||
}
|
}
|
||||||
|
@ -952,14 +952,14 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp)
|
|||||||
CBudgetProposal* pbudgetProposal = FindProposal((*it1).first);
|
CBudgetProposal* pbudgetProposal = FindProposal((*it1).first);
|
||||||
if(pbudgetProposal && pbudgetProposal->fValid && (nProp == 0 || (*it1).first == nProp)){
|
if(pbudgetProposal && pbudgetProposal->fValid && (nProp == 0 || (*it1).first == nProp)){
|
||||||
CInv inv(MSG_BUDGET_PROPOSAL, (*it1).second.GetHash());
|
CInv inv(MSG_BUDGET_PROPOSAL, (*it1).second.GetHash());
|
||||||
RelayInv(inv);
|
pfrom->PushInventory(inv);
|
||||||
|
|
||||||
//send votes
|
//send votes
|
||||||
std::map<uint256, CBudgetVote>::iterator it2 = pbudgetProposal->mapVotes.begin();
|
std::map<uint256, CBudgetVote>::iterator it2 = pbudgetProposal->mapVotes.begin();
|
||||||
while(it2 != pbudgetProposal->mapVotes.end()){
|
while(it2 != pbudgetProposal->mapVotes.end()){
|
||||||
if((*it2).second.fValid){
|
if((*it2).second.fValid){
|
||||||
CInv inv(MSG_BUDGET_VOTE, (*it2).second.GetHash());
|
CInv inv(MSG_BUDGET_VOTE, (*it2).second.GetHash());
|
||||||
RelayInv(inv);
|
pfrom->PushInventory(inv);
|
||||||
}
|
}
|
||||||
++it2;
|
++it2;
|
||||||
}
|
}
|
||||||
@ -972,14 +972,15 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp)
|
|||||||
CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first);
|
CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first);
|
||||||
if(pfinalizedBudget && pfinalizedBudget->fValid && (nProp == 0 || (*it3).first == nProp)){
|
if(pfinalizedBudget && pfinalizedBudget->fValid && (nProp == 0 || (*it3).first == nProp)){
|
||||||
CInv inv(MSG_BUDGET_FINALIZED, (*it3).second.GetHash());
|
CInv inv(MSG_BUDGET_FINALIZED, (*it3).second.GetHash());
|
||||||
RelayInv(inv);
|
pfrom->PushInventory(inv);
|
||||||
|
|
||||||
//send votes
|
//send votes
|
||||||
std::map<uint256, CFinalizedBudgetVote>::iterator it4 = pfinalizedBudget->mapVotes.begin();
|
std::map<uint256, CFinalizedBudgetVote>::iterator it4 = pfinalizedBudget->mapVotes.begin();
|
||||||
while(it4 != pfinalizedBudget->mapVotes.end()){
|
while(it4 != pfinalizedBudget->mapVotes.end()){
|
||||||
if((*it4).second.fValid)
|
if((*it4).second.fValid) {
|
||||||
CInv inv(MSG_BUDGET_FINALIZED_VOTE, (*it4).second.GetHash());
|
CInv inv(MSG_BUDGET_FINALIZED_VOTE, (*it4).second.GetHash());
|
||||||
RelayInv(inv);
|
pfrom->PushInventory(inv);
|
||||||
|
}
|
||||||
++it4;
|
++it4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,7 +763,7 @@ void CMasternodePayments::Sync(CNode* node, int nCountNeeded)
|
|||||||
CMasternodePaymentWinner winner = (*it).second;
|
CMasternodePaymentWinner winner = (*it).second;
|
||||||
if(winner.nBlockHeight >= chainActive.Tip()->nHeight-nCountNeeded && winner.nBlockHeight <= chainActive.Tip()->nHeight + 20) {
|
if(winner.nBlockHeight >= chainActive.Tip()->nHeight-nCountNeeded && winner.nBlockHeight <= chainActive.Tip()->nHeight + 20) {
|
||||||
CInv inv(MSG_MASTERNODE_WINNER, winner.GetHash());
|
CInv inv(MSG_MASTERNODE_WINNER, winner.GetHash());
|
||||||
RelayInv(inv);
|
node->PushInventory(inv);
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ void CMasternodeSync::Process()
|
|||||||
pnode->FulfilledRequest("mnsync");
|
pnode->FulfilledRequest("mnsync");
|
||||||
|
|
||||||
if((lastMasternodeList == 0 || lastMasternodeList > GetTime() - MASTERNODE_SYNC_TIMEOUT)
|
if((lastMasternodeList == 0 || lastMasternodeList > GetTime() - MASTERNODE_SYNC_TIMEOUT)
|
||||||
&& RequestedMasternodeAttempt <= 2){
|
&& RequestedMasternodeAttempt <= 4){
|
||||||
mnodeman.DsegUpdate(pnode);
|
mnodeman.DsegUpdate(pnode);
|
||||||
RequestedMasternodeAttempt++;
|
RequestedMasternodeAttempt++;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ void CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb)
|
|||||||
int nDoS = 0;
|
int nDoS = 0;
|
||||||
if(mnb.lastPing == CMasternodePing() || (mnb.lastPing != CMasternodePing() && mnb.lastPing.CheckAndUpdate(nDoS, false))) {
|
if(mnb.lastPing == CMasternodePing() || (mnb.lastPing != CMasternodePing() && mnb.lastPing.CheckAndUpdate(nDoS, false))) {
|
||||||
lastPing = mnb.lastPing;
|
lastPing = mnb.lastPing;
|
||||||
mapSeenMasternodePing[lastPing.GetHash()] = lastPing;
|
mnodeman.mapSeenMasternodePing[lastPing.GetHash()] = lastPing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,6 @@
|
|||||||
/** Masternode manager */
|
/** Masternode manager */
|
||||||
CMasternodeMan mnodeman;
|
CMasternodeMan mnodeman;
|
||||||
|
|
||||||
// Keep track of all broadcasts I've seen
|
|
||||||
map<uint256, CMasternodeBroadcast> mapSeenMasternodeBroadcast;
|
|
||||||
|
|
||||||
// Keep track of all pings I've seen
|
|
||||||
map<uint256, CMasternodePing> mapSeenMasternodePing;
|
|
||||||
|
|
||||||
struct CompareValueOnly
|
struct CompareValueOnly
|
||||||
{
|
{
|
||||||
bool operator()(const pair<int64_t, CTxIn>& t1,
|
bool operator()(const pair<int64_t, CTxIn>& t1,
|
||||||
@ -617,11 +611,11 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
CMasternodeBroadcast mnb;
|
CMasternodeBroadcast mnb;
|
||||||
vRecv >> mnb;
|
vRecv >> mnb;
|
||||||
|
|
||||||
if(mapSeenMasternodeBroadcast.count(mnb.GetHash())) { //seen
|
if(mnodeman.mapSeenMasternodeBroadcast.count(mnb.GetHash())) { //seen
|
||||||
masternodeSync.AddedMasternodeList();
|
masternodeSync.AddedMasternodeList();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mapSeenMasternodeBroadcast[mnb.GetHash()] = mnb;
|
mnodeman.mapSeenMasternodeBroadcast[mnb.GetHash()] = mnb;
|
||||||
|
|
||||||
int nDoS = 0;
|
int nDoS = 0;
|
||||||
if(!mnb.CheckAndUpdate(nDoS)){
|
if(!mnb.CheckAndUpdate(nDoS)){
|
||||||
@ -661,8 +655,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
|
|
||||||
if(fDebug) LogPrintf("mnp - Masternode ping, vin: %s\n", mnp.vin.ToString());
|
if(fDebug) LogPrintf("mnp - Masternode ping, vin: %s\n", mnp.vin.ToString());
|
||||||
|
|
||||||
if(mapSeenMasternodePing.count(mnp.GetHash())) return; //seen
|
if(mnodeman.mapSeenMasternodePing.count(mnp.GetHash())) return; //seen
|
||||||
mapSeenMasternodePing[mnp.GetHash()] = mnp;
|
mnodeman.mapSeenMasternodePing[mnp.GetHash()] = mnp;
|
||||||
|
|
||||||
int nDoS = 0;
|
int nDoS = 0;
|
||||||
if(mnp.CheckAndUpdate(nDoS)) return;
|
if(mnp.CheckAndUpdate(nDoS)) return;
|
||||||
@ -724,15 +718,11 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
if(mn.IsEnabled()) {
|
if(mn.IsEnabled()) {
|
||||||
if(fDebug) 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());
|
||||||
if(vin == CTxIn()){
|
if(vin == CTxIn()){
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CInv inv(MSG_MASTERNODE_ANNOUNCE, CMasternodeBroadcast(mn).GetHash());
|
||||||
ss.reserve(1000);
|
pfrom->PushInventory(inv);
|
||||||
ss << CMasternodeBroadcast(mn);
|
|
||||||
pfrom->PushMessage("mnb", ss);
|
|
||||||
} else if (vin == mn.vin) {
|
} else if (vin == mn.vin) {
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CInv inv(MSG_MASTERNODE_ANNOUNCE, CMasternodeBroadcast(mn).GetHash());
|
||||||
ss.reserve(1000);
|
pfrom->PushInventory(inv);
|
||||||
ss << CMasternodeBroadcast(mn);
|
|
||||||
pfrom->PushMessage("mnb", ss);
|
|
||||||
|
|
||||||
LogPrintf("dseg - Sent 1 Masternode entries to %s\n", pfrom->addr.ToString().c_str());
|
LogPrintf("dseg - Sent 1 Masternode entries to %s\n", pfrom->addr.ToString().c_str());
|
||||||
return;
|
return;
|
||||||
|
@ -20,12 +20,6 @@ using namespace std;
|
|||||||
|
|
||||||
class CMasternodeMan;
|
class CMasternodeMan;
|
||||||
|
|
||||||
// Keep track of all broadcasts I've seen
|
|
||||||
extern map<uint256, CMasternodeBroadcast> mapSeenMasternodeBroadcast;
|
|
||||||
|
|
||||||
// Keep track of all pings I've seen
|
|
||||||
extern map<uint256, CMasternodePing> mapSeenMasternodePing;
|
|
||||||
|
|
||||||
extern CMasternodeMan mnodeman;
|
extern CMasternodeMan mnodeman;
|
||||||
void DumpMasternodes();
|
void DumpMasternodes();
|
||||||
|
|
||||||
@ -71,6 +65,11 @@ private:
|
|||||||
std::map<COutPoint, int64_t> mWeAskedForMasternodeListEntry;
|
std::map<COutPoint, int64_t> mWeAskedForMasternodeListEntry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Keep track of all broadcasts I've seen
|
||||||
|
map<uint256, CMasternodeBroadcast> mapSeenMasternodeBroadcast;
|
||||||
|
// Keep track of all pings I've seen
|
||||||
|
map<uint256, CMasternodePing> mapSeenMasternodePing;
|
||||||
|
|
||||||
// keep track of dsq count to prevent masternodes from gaming darksend queue
|
// keep track of dsq count to prevent masternodes from gaming darksend queue
|
||||||
int64_t nDsqCount;
|
int64_t nDsqCount;
|
||||||
|
|
||||||
@ -78,12 +77,15 @@ public:
|
|||||||
|
|
||||||
template <typename Stream, typename Operation>
|
template <typename Stream, typename Operation>
|
||||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
READWRITE(vMasternodes);
|
READWRITE(vMasternodes);
|
||||||
READWRITE(mAskedUsForMasternodeList);
|
READWRITE(mAskedUsForMasternodeList);
|
||||||
READWRITE(mWeAskedForMasternodeList);
|
READWRITE(mWeAskedForMasternodeList);
|
||||||
READWRITE(mWeAskedForMasternodeListEntry);
|
READWRITE(mWeAskedForMasternodeListEntry);
|
||||||
READWRITE(nDsqCount);
|
READWRITE(nDsqCount);
|
||||||
|
|
||||||
|
READWRITE(mapSeenMasternodeBroadcast);
|
||||||
|
READWRITE(mapSeenMasternodePing);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMasternodeMan();
|
CMasternodeMan();
|
||||||
|
@ -1799,7 +1799,6 @@ void RelayTransactionLockReq(const CTransaction& tx, bool relayToAll)
|
|||||||
|
|
||||||
pnode->PushMessage("ix", tx);
|
pnode->PushMessage("ix", tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelayInv(CInv &inv, const int minProtoVersion) {
|
void RelayInv(CInv &inv, const int minProtoVersion) {
|
||||||
|
@ -693,7 +693,7 @@ public:
|
|||||||
class CTransaction;
|
class CTransaction;
|
||||||
void RelayTransaction(const CTransaction& tx);
|
void RelayTransaction(const CTransaction& tx);
|
||||||
void RelayTransaction(const CTransaction& tx, const CDataStream& ss);
|
void RelayTransaction(const CTransaction& tx, const CDataStream& ss);
|
||||||
void RelayTransactionLockReq(const CTransaction& tx, bool relayToAll=false);
|
void RelayTransactionLockReq(const CTransaction& tx, bool relayToAll=false);
|
||||||
void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
|
void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
|
||||||
|
|
||||||
/** Access to the (IP) address database (peers.dat) */
|
/** Access to the (IP) address database (peers.dat) */
|
||||||
|
Loading…
Reference in New Issue
Block a user