diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -855,11 +855,11 @@ } strUsage += HelpMessageGroup(_("Hard Fork options:")); - strUsage += - HelpMessageOpt("-uahfstarttime=", - strprintf(_("UAHF activation (integer) POSIX " - "time, seconds since epoch (default: %u)"), - DEFAULT_UAHF_START_TIME)); + strUsage += HelpMessageOpt( + "-uahfstarttime=", + strprintf(_("(Deprecated) UAHF activation (integer) " + "POSIX time, seconds since epoch (default: %u)"), + DEFAULT_UAHF_START_TIME)); return strUsage; } @@ -1408,14 +1408,17 @@ return InitError(msg); } - const int64_t nProposedUAHFStartTime = + const int64_t uahfFromArgs = GetArg("-uahfstarttime", DEFAULT_UAHF_START_TIME); - if (!config.SetUAHFStartTime(nProposedUAHFStartTime)) { - return InitError( - strprintf(_("Unable to set uahfstarttime to the value (%d)"), - nProposedUAHFStartTime)); - assert(nProposedUAHFStartTime == config.GetUAHFStartTime()); + if (uahfFromArgs != int64_t(DEFAULT_UAHF_START_TIME)) { + LogPrintf("WARNING: Deprecated use of -uahfstarttime=%d parameter\n", + uahfFromArgs); + } + if (!config.SetUAHFStartTime(uahfFromArgs)) { + return InitError(strprintf( + _("Unable to set uahfstarttime to the value (%d)"), uahfFromArgs)); } + assert(config.GetUAHFStartTime() == uahfFromArgs); // block pruning; get the amount of disk space (in MiB) to allot for block & // undo files diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1682,6 +1682,12 @@ } else if (strCommand == NetMsgType::ADDR) { + // We don't want addr from non-Cash peers if we're on the Cash chain + // already. + if (!(pfrom->nServices & NODE_BITCOIN_CASH) && fActiveChainTipIsUAHF) { + return true; + } + std::vector vAddr; vRecv >> vAddr; @@ -1696,15 +1702,6 @@ return error("message addr size() = %u", vAddr.size()); } - // Don't want addr from non-Cash peers if we're on the Cash chain - // already - if (!(pfrom->nServices & NODE_BITCOIN_CASH)) { - LOCK(cs_main); - if (IsUAHFenabledForCurrentBlock(config)) { - return true; - } - } - // Store the new addresses std::vector vAddrOk; int64_t nNow = GetAdjustedTime(); diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -190,6 +190,9 @@ extern bool fCheckBlockIndex; extern bool fCheckpointsEnabled; extern size_t nCoinCacheUsage; +/** True if and only if chainActive.Tip()'s medianTimePast >= UAHFStartTime. + * Updated in validation.cpp :: UpdateTip() */ +extern std::atomic_bool fActiveChainTipIsUAHF; /** A fee rate smaller than this is considered zero fee (for relaying, mining * and transaction creation) */ diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -74,6 +74,8 @@ bool fRequireStandard = true; bool fCheckBlockIndex = false; bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED; +std::atomic_bool fActiveChainTipIsUAHF(false); + size_t nCoinCacheUsage = 5000 * 300; uint64_t nPruneTarget = 0; int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; @@ -2236,6 +2238,10 @@ chainActive.SetTip(pindexNew); + // other code that cares about being conditional on UAHF + // might need this flag + fActiveChainTipIsUAHF = IsUAHFenabledForCurrentBlock(config); + // New best block mempool.AddTransactionsUpdated(1);