diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 49d7ee641..f97b65eb2 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -1,4 +1,5 @@ +#include "addrman.h" #include "protocol.h" #include "activemasternode.h" #include "masternodeman.h" @@ -260,6 +261,8 @@ bool CActiveMasternode::Register(std::string strService, std::string strKeyMaste return false; } + addrman.Add(CAddress(service), CNetAddr("127.0.0.1"), 2*60*60); + return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage); } diff --git a/src/init.cpp b/src/init.cpp index cf9ee0e5d..e9ef65b99 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -169,7 +169,7 @@ void PrepareShutdown() GenerateBitcoins(false, NULL, 0); #endif StopNode(); - //DumpMasternodes(); + DumpMasternodes(); //DumpBudgets(); //DumpMasternodePayments(); UnregisterNodeSignals(GetNodeSignals()); @@ -1410,29 +1410,29 @@ bool AppInit2(boost::thread_group& threadGroup) // ********************************************************* Step 10: setup DarkSend + + uiInterface.InitMessage(_("Loading masternode cache...")); + + CMasternodeDB mndb; + CMasternodeDB::ReadResult readResult = mndb.Read(mnodeman); + if (readResult == CMasternodeDB::FileError) + LogPrintf("Missing masternode cache file - mncache.dat, will try to recreate\n"); + else if (readResult != CMasternodeDB::Ok) + { + LogPrintf("Error reading mncache.dat: "); + if(readResult == CMasternodeDB::IncorrectFormat) + LogPrintf("magic is ok but data has invalid format, will try to recreate\n"); + else + LogPrintf("file format is unknown or invalid, please fix it manually\n"); + } + /* We sync all of this information on boot anyway, as it's kept on the network so there's really no point. - Also, it seems it might be causing some edge cases where clients can get stuck. I think it's better to just + Also, it seems it might be causing some edge cases where clients can get stuck. I think it's better to just sync from the network instead. // --------- - - // uiInterface.InitMessage(_("Loading masternode cache...")); - - // CMasternodeDB mndb; - // CMasternodeDB::ReadResult readResult = mndb.Read(mnodeman); - // if (readResult == CMasternodeDB::FileError) - // LogPrintf("Missing masternode cache file - mncache.dat, will try to recreate\n"); - // else if (readResult != CMasternodeDB::Ok) - // { - // LogPrintf("Error reading mncache.dat: "); - // if(readResult == CMasternodeDB::IncorrectFormat) - // LogPrintf("magic is ok but data has invalid format, will try to recreate\n"); - // else - // LogPrintf("file format is unknown or invalid, please fix it manually\n"); - // } - // uiInterface.InitMessage(_("Loading budget cache...")); // CBudgetDB budgetdb; diff --git a/src/masternode.cpp b/src/masternode.cpp index e9aa71652..ddaa23d00 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -292,6 +292,7 @@ CMasternodeBroadcast::CMasternodeBroadcast() unitTest = false; allowFreeTx = true; protocolVersion = PROTOCOL_VERSION; + nLastDsq = 0; nScanningErrorCount = 0; nLastScanningErrorBlockHeight = 0; } diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index b32d9d6d9..88f66e0be 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -859,6 +859,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData // mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below, // after that they just need to match if(count == -1 && pmn->pubkey == pubkey && (GetAdjustedTime() - pmn->sigTime > MASTERNODE_MIN_MNB_SECONDS)){ + if(pmn->protocolVersion > GETHEADERS_VERSION && sigTime - pmn->lastPing.sigTime < MASTERNODE_MIN_MNB_SECONDS) return; if(pmn->sigTime < sigTime){ //take the newest entry LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str()); if(pmn->protocolVersion < GETHEADERS_VERSION) { @@ -892,7 +893,14 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData return; } - if(fDebug) LogPrintf("dsee - Got NEW OLD Masternode entry %s\n", addr.ToString().c_str()); + static std::map mapSeenDsee; + if(mapSeenDsee.count(vin.prevout.ToString())) { + LogPrint("mastenrode", "dsee - already seen this vin %s %lld\n", vin.prevout.ToString(), mapSeenDsee[vin.prevout.ToString()]); + return; + } + mapSeenDsee.insert(make_pair(vin.prevout.ToString(), GetAdjustedTime())); + + LogPrint("masternode", "dsee - Got NEW OLD Masternode entry %s\n", addr.ToString().c_str()); // make sure it's still unspent // - this is checked later by .check() in many places and by ThreadCheckDarkSendPool() @@ -952,7 +960,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData mn.Check(true); // add v11 masternodes, v12 should be added by mnb only if(protocolVersion < GETHEADERS_VERSION) { - if(fDebug) LogPrintf("dsee - Accepted OLD Masternode entry %i %i\n", count, current); + LogPrint("masternode", "dsee - Accepted OLD Masternode entry %i %i\n", count, current); Add(mn); } if(mn.IsEnabled()) {