From: MASM fan Date: Sat, 24 Jan 2015 01:12:12 +0000 (-0800) Subject: Add new options for broadcast and keepalive intervals X-Git-Tag: nvc-v0.5.3~138 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=ce96f7482a5212f9d607e7ce631be557c4359c3d;hp=21c36b54b1d1d8c43688f9fbf4a02ce1e4d925c1;p=novacoin.git Add new options for broadcast and keepalive intervals --- diff --git a/src/init.cpp b/src/init.cpp index cc66c3d..3e55c3c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -38,6 +38,10 @@ bool fUseFastStakeMiner; bool fUseMemoryLog; enum Checkpoints::CPMode CheckpointsMode; +// Ping and address broadcast intervals +extern int64_t nPingInterval; +extern int64_t nBroadcastInterval; + ////////////////////////////////////////////////////////////////////////////// // // Shutdown @@ -374,17 +378,25 @@ bool AppInit2() fUseMemoryLog = GetBoolArg("-memorylog", true); nMinerSleep = GetArg("-minersleep", 500); + // Ping and address broadcast intervals + nPingInterval = max(10 * 60, GetArg("-keepalive", 30 * 60)); + + nBroadcastInterval = max(6 * 60 * 60, GetArg("-addrsetlifetime", 24 * 60 * 60)); + CheckpointsMode = Checkpoints::STRICT; std::string strCpMode = GetArg("-cppolicy", "strict"); - if(strCpMode == "strict") + if(strCpMode == "strict") { CheckpointsMode = Checkpoints::STRICT; + } - if(strCpMode == "advisory") + if(strCpMode == "advisory") { CheckpointsMode = Checkpoints::ADVISORY; + } - if(strCpMode == "permissive") + if(strCpMode == "permissive") { CheckpointsMode = Checkpoints::PERMISSIVE; + } nDerivationMethodIndex = 0; diff --git a/src/main.cpp b/src/main.cpp index a091f6d..9d38e93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,6 +79,10 @@ const string strMessageMagic = "NovaCoin Signed Message:\n"; int64_t nTransactionFee = MIN_TX_FEE; int64_t nMinimumInputValue = MIN_TX_FEE; +// Ping and address broadcast intervals +int64_t nPingInterval = 30 * 60; +int64_t nBroadcastInterval = 24 * 60 * 60; + extern enum Checkpoints::CPMode CheckpointsMode; ////////////////////////////////////////////////////////////////////////////// @@ -3932,7 +3936,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Keep-alive ping. We send a nonce of zero because we don't use it anywhere // right now. - if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty()) { + if (pto->nLastSend && GetTime() - pto->nLastSend > nPingInterval && pto->vSend.empty()) { uint64_t nonce = 0; if (pto->nVersion > BIP0031_VERSION) pto->PushMessage("ping", nonce); @@ -3951,7 +3955,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Address refresh broadcast static int64_t nLastRebroadcast; - if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) + if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > nBroadcastInterval)) { { LOCK(cs_vNodes);