diff --git a/src/chainparams.cpp b/src/chainparams.cpp index cd8f406..18edc24 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -242,7 +242,7 @@ class CMainParams : public CChainParams fMineBlocksOnDemand = false; fSkipProofOfWorkCheck = false; fTestnetToBeDeprecatedFieldRPC = false; - + fHeadersFirstSyncingActive = false; nPoolMaxTransactions = 3; strSporkKey = "044a30edfb288d8973761070dc8b456d429c7b8872d475a837e09e71d3b710c08055852a50de199ee04c0643ebb4bce1c52a27c63cec13c62cf2f84eda00d8a3a6"; diff --git a/src/chainparams.h b/src/chainparams.h index 95196ce..c436e21 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -62,6 +62,8 @@ class CChainParams const CBlock& GenesisBlock() const { return genesis; } /** Make miner wait to have peers to avoid wasting work */ bool MiningRequiresPeers() const { return fMiningRequiresPeers; } + /** Headers first syncing is disabled */ + bool HeadersFirstSyncingActive() const { return fHeadersFirstSyncingActive; }; /** Default value for -checkmempool and -checkblockindex argument */ bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; } /** Allow mining of a min-difficulty block */ @@ -152,6 +154,7 @@ class CChainParams bool fMineBlocksOnDemand; bool fSkipProofOfWorkCheck; bool fTestnetToBeDeprecatedFieldRPC; + bool fHeadersFirstSyncingActive; int nPoolMaxTransactions; std::string strSporkKey; std::string strObfuscationPoolDummyAddress; diff --git a/src/main.cpp b/src/main.cpp index 640e6f8..836dac8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6037,7 +6037,8 @@ bool fRequestedSporksIDB = false; bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived) { RandAddSeedPerfmon(); - LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); + if (fDebug) + LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; @@ -6327,7 +6328,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - else if (strCommand == "getblocks") { + else if (strCommand == "getblocks" || strCommand == "getheaders") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; @@ -6359,7 +6360,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - else if (strCommand == "headers") { + else if (strCommand == "headers" && Params().HeadersFirstSyncingActive()) { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; @@ -6388,8 +6389,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end vector vHeaders; int nLimit = MAX_HEADERS_RESULTS; - - LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id); + if (fDebug) + LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id); for (; pindex; pindex = chainActive.Next(pindex)) { vHeaders.push_back(pindex->GetBlockHeader()); @@ -6567,7 +6568,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing + else if (strCommand == "headers" && Params().HeadersFirstSyncingActive() && !fImporting && !fReindex) // Ignore headers received while importing { std::vector headers; diff --git a/src/miner.cpp b/src/miner.cpp index 75d3b7e..e0be062 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -585,7 +585,7 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake) while (chainActive.Tip()->nTime < 1471482000 || vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || nReserveBalance >= pwallet->GetBalance() || !masternodeSync.IsSynced()) { nLastCoinStakeSearchInterval = 0; - LogPrint("miner", "MNPCoinMiner wait 5 seconds (%u, %d, %d, %d)\n", vNodes.size(), pwallet->IsLocked(), fMintableCoins, masternodeSync.IsBlockchainSynced()); +// LogPrint("miner", "MNPCoinMiner wait 5 seconds (%u, %d, %d, %d)\n", vNodes.size(), pwallet->IsLocked(), fMintableCoins, masternodeSync.IsBlockchainSynced()); MilliSleep(5000); if (!fGenerateBitcoins && !fProofOfStake) continue; @@ -595,7 +595,7 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake) { if (GetTime() - mapHashedBlocks[chainActive.Tip()->nHeight] < max(pwallet->nHashInterval, (unsigned int)1)) // wait half of the nHashDrift with max wait of 3 minutes { - LogPrint("miner", "MNPCoinMiner wait half of the nHashDrift\n"); +// LogPrint("miner", "MNPCoinMiner wait half of the nHashDrift\n"); MilliSleep(5000); continue; }