This commit is contained in:
UdjinM6 2015-08-12 15:27:58 +03:00
parent 5e9fbabd90
commit cbecd3bfa8
4 changed files with 32 additions and 20 deletions

View File

@ -1,4 +1,5 @@
#include "addrman.h"
#include "protocol.h" #include "protocol.h"
#include "activemasternode.h" #include "activemasternode.h"
#include "masternodeman.h" #include "masternodeman.h"
@ -260,6 +261,8 @@ bool CActiveMasternode::Register(std::string strService, std::string strKeyMaste
return false; return false;
} }
addrman.Add(CAddress(service), CNetAddr("127.0.0.1"), 2*60*60);
return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage); return Register(vin, CService(strService), keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage);
} }

View File

@ -169,7 +169,7 @@ void PrepareShutdown()
GenerateBitcoins(false, NULL, 0); GenerateBitcoins(false, NULL, 0);
#endif #endif
StopNode(); StopNode();
//DumpMasternodes(); DumpMasternodes();
//DumpBudgets(); //DumpBudgets();
//DumpMasternodePayments(); //DumpMasternodePayments();
UnregisterNodeSignals(GetNodeSignals()); UnregisterNodeSignals(GetNodeSignals());
@ -1410,6 +1410,22 @@ bool AppInit2(boost::thread_group& threadGroup)
// ********************************************************* Step 10: setup DarkSend // ********************************************************* 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. We sync all of this information on boot anyway, as it's kept on the network so there's really no point.
@ -1417,22 +1433,6 @@ bool AppInit2(boost::thread_group& threadGroup)
sync from the network instead. 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...")); // uiInterface.InitMessage(_("Loading budget cache..."));
// CBudgetDB budgetdb; // CBudgetDB budgetdb;

View File

@ -292,6 +292,7 @@ CMasternodeBroadcast::CMasternodeBroadcast()
unitTest = false; unitTest = false;
allowFreeTx = true; allowFreeTx = true;
protocolVersion = PROTOCOL_VERSION; protocolVersion = PROTOCOL_VERSION;
nLastDsq = 0;
nScanningErrorCount = 0; nScanningErrorCount = 0;
nLastScanningErrorBlockHeight = 0; nLastScanningErrorBlockHeight = 0;
} }

View File

@ -859,6 +859,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
// mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below, // mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below,
// after that they just need to match // after that they just need to match
if(count == -1 && pmn->pubkey == pubkey && (GetAdjustedTime() - pmn->sigTime > MASTERNODE_MIN_MNB_SECONDS)){ 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 if(pmn->sigTime < sigTime){ //take the newest entry
LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str()); LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str());
if(pmn->protocolVersion < GETHEADERS_VERSION) { if(pmn->protocolVersion < GETHEADERS_VERSION) {
@ -892,7 +893,14 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
return; return;
} }
if(fDebug) LogPrintf("dsee - Got NEW OLD Masternode entry %s\n", addr.ToString().c_str()); static std::map<std::string, int64_t> 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 // make sure it's still unspent
// - this is checked later by .check() in many places and by ThreadCheckDarkSendPool() // - 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); mn.Check(true);
// add v11 masternodes, v12 should be added by mnb only // add v11 masternodes, v12 should be added by mnb only
if(protocolVersion < GETHEADERS_VERSION) { 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); Add(mn);
} }
if(mn.IsEnabled()) { if(mn.IsEnabled()) {