diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -1302,7 +1302,7 @@ } bool AppInitParameterInteraction(Config &config) { - const CChainParams &chainparams = Params(); + const CChainParams &chainparams = config.GetChainParams(); // Step 2: parameter interactions // also see: InitParameterInteraction() diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -352,7 +352,7 @@ SOCKET hSocket; bool proxyConnectionFailed = false; if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, - Params().GetDefaultPort(), + config->GetChainParams().GetDefaultPort(), nConnectTimeout, &proxyConnectionFailed) : ConnectSocket(addrConnect, hSocket, nConnectTimeout, &proxyConnectionFailed)) { @@ -1671,7 +1671,8 @@ } } - const std::vector &vSeeds = Params().DNSSeeds(); + const std::vector &vSeeds = + config->GetChainParams().DNSSeeds(); int found = 0; LogPrintf("Loading addresses from DNS seeds (could take a while)\n"); @@ -1687,9 +1688,9 @@ 0, true)) { for (const CNetAddr &ip : vIPs) { int nOneDay = 24 * 3600; - CAddress addr = - CAddress(CService(ip, Params().GetDefaultPort()), - requiredServiceBits); + CAddress addr = CAddress( + CService(ip, config->GetChainParams().GetDefaultPort()), + requiredServiceBits); // Use a random age between 3 and 7 days old. addr.nTime = GetTime() - 3 * nOneDay - GetRand(4 * nOneDay); vAdd.push_back(addr); @@ -1794,7 +1795,8 @@ "available.\n"); CNetAddr local; LookupHost("127.0.0.1", local, false); - addrman.Add(convertSeed6(Params().FixedSeeds()), local); + addrman.Add(convertSeed6(config->GetChainParams().FixedSeeds()), + local); done = true; } } @@ -1894,7 +1896,8 @@ // do not allow non-default ports, unless after 50 invalid addresses // selected already. - if (addr.GetPort() != Params().GetDefaultPort() && nTries < 50) { + if (addr.GetPort() != config->GetChainParams().GetDefaultPort() && + nTries < 50) { continue; } @@ -1956,8 +1959,8 @@ } for (const std::string &strAddNode : lAddresses) { - CService service( - LookupNumeric(strAddNode.c_str(), Params().GetDefaultPort())); + CService service(LookupNumeric( + strAddNode.c_str(), config->GetChainParams().GetDefaultPort())); if (service.IsValid()) { // strAddNode is an IP:port auto it = mapConnected.find(service); @@ -2008,8 +2011,9 @@ // OpenNetworkConnection can detect existing connections to that // IP/port. tried = true; - CService service(LookupNumeric(info.strAddedNode.c_str(), - Params().GetDefaultPort())); + CService service( + LookupNumeric(info.strAddedNode.c_str(), + config->GetChainParams().GetDefaultPort())); OpenNetworkConnection(CAddress(service, NODE_NONE), false, &grant, info.strAddedNode.c_str(), false, false, true); @@ -2927,7 +2931,8 @@ std::vector serializedHeader; serializedHeader.reserve(CMessageHeader::HEADER_SIZE); uint256 hash = Hash(msg.data.data(), msg.data.data() + nMessageSize); - CMessageHeader hdr(Params().NetMagic(), msg.command.c_str(), nMessageSize); + CMessageHeader hdr(config->GetChainParams().NetMagic(), msg.command.c_str(), + nMessageSize); memcpy(hdr.pchChecksum, hash.begin(), CMessageHeader::CHECKSUM_SIZE); CVectorWriter{SER_NETWORK, INIT_PROTO_VERSION, serializedHeader, 0, hdr}; diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3077,7 +3077,7 @@ bool ProcessMessages(const Config &config, CNode *pfrom, CConnman &connman, const std::atomic &interruptMsgProc) { - const CChainParams &chainparams = Params(); + const CChainParams &chainparams = config.GetChainParams(); // // Message format // (4) message start @@ -3229,7 +3229,8 @@ bool SendMessages(const Config &config, CNode *pto, CConnman &connman, const std::atomic &interruptMsgProc) { - const Consensus::Params &consensusParams = Params().GetConsensus(); + const Consensus::Params &consensusParams = + config.GetChainParams().GetConsensus(); // Don't send anything until the version handshake is complete if (!pto->fSuccessfullyConnected || pto->fDisconnect) { diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -969,7 +969,7 @@ unsigned int height = (unsigned int)heightParam; unsigned int chainHeight = (unsigned int)chainActive.Height(); - if (chainHeight < Params().PruneAfterHeight()) { + if (chainHeight < config.GetChainParams().PruneAfterHeight()) { throw JSONRPCError(RPC_MISC_ERROR, "Blockchain is too short for pruning."); } else if (height > chainHeight) { @@ -1295,7 +1295,7 @@ LOCK(cs_main); UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("chain", Params().NetworkIDString())); + obj.push_back(Pair("chain", config.GetChainParams().NetworkIDString())); obj.push_back(Pair("blocks", int(chainActive.Height()))); obj.push_back( Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1)); @@ -1306,11 +1306,13 @@ Pair("mediantime", int64_t(chainActive.Tip()->GetMedianTimePast()))); obj.push_back( Pair("verificationprogress", - GuessVerificationProgress(Params().TxData(), chainActive.Tip()))); + GuessVerificationProgress(config.GetChainParams().TxData(), + chainActive.Tip()))); obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex())); obj.push_back(Pair("pruned", fPruneMode)); - const Consensus::Params &consensusParams = Params().GetConsensus(); + const Consensus::Params &consensusParams = + config.GetChainParams().GetConsensus(); CBlockIndex *tip = chainActive.Tip(); UniValue softforks(UniValue::VARR); UniValue bip9_softforks(UniValue::VOBJ); @@ -1659,8 +1661,8 @@ const CBlockIndex *pindex; // By default: 1 month - int blockcount = - 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; + int blockcount = 30 * 24 * 60 * 60 / + config.GetChainParams().GetConsensus().nPowTargetSpacing; bool havehash = !request.params[1].isNull(); uint256 hash; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -257,7 +257,7 @@ obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("networkhashps", getnetworkhashps(config, request))); obj.push_back(Pair("pooledtx", uint64_t(mempool.size()))); - obj.push_back(Pair("chain", Params().NetworkIDString())); + obj.push_back(Pair("chain", config.GetChainParams().NetworkIDString())); return obj; } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -113,8 +113,9 @@ obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()))); obj.push_back(Pair("difficulty", double(GetDifficulty(chainActive.Tip())))); - obj.push_back(Pair( - "testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET)); + obj.push_back(Pair("testnet", + config.GetChainParams().NetworkIDString() == + CBaseChainParams::TESTNET)); #ifdef ENABLE_WALLET if (pwallet) { obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); @@ -543,7 +544,7 @@ " Pass 0 to go back to using the system time."); } - if (!Params().MineBlocksOnDemand()) { + if (!config.GetChainParams().MineBlocksOnDemand()) { throw std::runtime_error( "setmocktime for regression testing (-regtest mode) only"); } diff --git a/src/secp256k1/src/modules/recovery/main_impl.h b/src/secp256k1/src/modules/recovery/main_impl.h old mode 100755 new mode 100644