diff --git a/src/gtest/test_foundersreward.cpp b/src/gtest/test_foundersreward.cpp index 72bdc9fe7..538f42598 100644 --- a/src/gtest/test_foundersreward.cpp +++ b/src/gtest/test_foundersreward.cpp @@ -150,7 +150,7 @@ TEST(FoundersRewardTest, RegtestGetLastBlockBlossom) { TEST(FoundersRewardTest, MainnetGetLastBlock) { SelectParams(CBaseChainParams::MAIN); - auto params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(); int lastFRHeight = GetLastFoundersRewardHeight(params); EXPECT_EQ(0, params.Halving(lastFRHeight)); EXPECT_EQ(1, params.Halving(lastFRHeight + 1)); diff --git a/src/gtest/test_noteencryption.cpp b/src/gtest/test_noteencryption.cpp index a9b19f184..6dae057af 100644 --- a/src/gtest/test_noteencryption.cpp +++ b/src/gtest/test_noteencryption.cpp @@ -189,7 +189,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled) UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, overwinterActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, saplingActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_CANOPY, canopyActivationHeight); - auto params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(); using namespace libzcash; auto xsk = SaplingSpendingKey(uint256()).expanded_spending_key(); @@ -280,7 +280,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, overwinterActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, saplingActivationHeight); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_CANOPY, canopyActivationHeight); - auto params = Params().GetConsensus(); + const Consensus::Params& params = Params().GetConsensus(); using namespace libzcash; auto xsk = SaplingSpendingKey(uint256()).expanded_spending_key(); diff --git a/src/gtest/test_transaction_builder.cpp b/src/gtest/test_transaction_builder.cpp index 1833e99ab..571988608 100644 --- a/src/gtest/test_transaction_builder.cpp +++ b/src/gtest/test_transaction_builder.cpp @@ -251,7 +251,7 @@ TEST(TransactionBuilder, SproutToSproutAndSapling) { TEST(TransactionBuilder, ThrowsOnTransparentInputWithoutKeyStore) { SelectParams(CBaseChainParams::REGTEST); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto builder = TransactionBuilder(consensusParams, 1); ASSERT_THROW(builder.AddTransparentInput(COutPoint(), CScript(), 1), std::runtime_error); @@ -260,7 +260,7 @@ TEST(TransactionBuilder, ThrowsOnTransparentInputWithoutKeyStore) TEST(TransactionBuilder, RejectsInvalidTransparentOutput) { SelectParams(CBaseChainParams::REGTEST); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); // Default CTxDestination type is an invalid address CTxDestination taddr; @@ -271,7 +271,7 @@ TEST(TransactionBuilder, RejectsInvalidTransparentOutput) TEST(TransactionBuilder, RejectsInvalidTransparentChangeAddress) { SelectParams(CBaseChainParams::REGTEST); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); // Default CTxDestination type is an invalid address CTxDestination taddr; @@ -454,7 +454,7 @@ TEST(TransactionBuilder, CheckSaplingTxVersion) { SelectParams(CBaseChainParams::REGTEST); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto sk = libzcash::SaplingSpendingKey::random(); auto expsk = sk.expanded_spending_key(); diff --git a/src/gtest/test_validation.cpp b/src/gtest/test_validation.cpp index fd48b49ed..a411bfc2d 100644 --- a/src/gtest/test_validation.cpp +++ b/src/gtest/test_validation.cpp @@ -134,7 +134,7 @@ TEST(Validation, ContextualCheckInputsDetectsOldBranchId) { UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, 10); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, 20); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_BLOSSOM, 30); - auto consensusParams = Params(CBaseChainParams::REGTEST).GetConsensus(); + const Consensus::Params& consensusParams = Params(CBaseChainParams::REGTEST).GetConsensus(); auto overwinterBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_OVERWINTER].nBranchId; auto saplingBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_SAPLING].nBranchId; diff --git a/src/main.cpp b/src/main.cpp index d097d8b07..60b8789f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2632,7 +2632,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(const CChainParams&), LOCK(cs); - Consensus::Params consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); int BLOCKS_EXPECTED; // TODO: This can be simplified when the Blossom activation height is set @@ -4898,7 +4898,7 @@ bool RewindBlockIndex(const CChainParams& chainparams, bool& clearWitnessCaches) // - BLOCK_ACTIVATES_UPGRADE is set only on blocks that activate upgrades. // - nCachedBranchId for each block matches what we expect. auto sufficientlyValidated = [&chainparams](const CBlockIndex* pindex) { - auto consensus = chainparams.GetConsensus(); + const Consensus::Params& consensus = chainparams.GetConsensus(); bool fFlagSet = pindex->nStatus & BLOCK_ACTIVATES_UPGRADE; bool fFlagExpected = IsActivationHeightForAnyUpgrade(pindex->nHeight, consensus); return fFlagSet == fFlagExpected && diff --git a/src/metrics.cpp b/src/metrics.cpp index be1d9c926..e54668efd 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -470,7 +470,7 @@ int printMetrics(size_t cols, bool mining) { LOCK2(cs_main, cs_metrics); boost::strict_lock_ptr> u = trackedBlocks.synchronize(); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto tipHeight = chainActive.Height(); // Update orphans and calculate subsidies diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 7db227298..07086422a 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -898,7 +898,7 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp) if (nHeight < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - auto consensus = Params().GetConsensus(); + const Consensus::Params& consensus = Params().GetConsensus(); CAmount nBlockSubsidy = GetBlockSubsidy(nHeight, consensus); CAmount nMinerReward = nBlockSubsidy; CAmount nFoundersReward = 0; diff --git a/src/wallet/asyncrpcoperation_saplingmigration.cpp b/src/wallet/asyncrpcoperation_saplingmigration.cpp index f94055350..45845720d 100644 --- a/src/wallet/asyncrpcoperation_saplingmigration.cpp +++ b/src/wallet/asyncrpcoperation_saplingmigration.cpp @@ -69,7 +69,7 @@ void AsyncRPCOperation_saplingmigration::main() { bool AsyncRPCOperation_saplingmigration::main_impl() { LogPrint("zrpcunsafe", "%s: Beginning AsyncRPCOperation_saplingmigration.\n", getId()); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto nextActivationHeight = NextActivationHeight(targetHeight_, consensusParams); if (nextActivationHeight && targetHeight_ + MIGRATION_EXPIRY_DELTA >= nextActivationHeight.get()) { LogPrint("zrpcunsafe", "%s: Migration txs would be created before a NU activation but may expire after. Skipping this round.\n", getId()); diff --git a/src/wallet/test/rpc_wallet_tests.cpp b/src/wallet/test/rpc_wallet_tests.cpp index 64f953412..df41a37de 100644 --- a/src/wallet/test/rpc_wallet_tests.cpp +++ b/src/wallet/test/rpc_wallet_tests.cpp @@ -1169,7 +1169,7 @@ BOOST_AUTO_TEST_CASE(asyncrpcoperation_sign_send_raw_transaction) { BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) { SelectParams(CBaseChainParams::TESTNET); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1394,7 +1394,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_taddr_to_sapling) auto pa = pwalletMain->GenerateNewSaplingZKey(); std::string zaddr1 = keyIO.EncodePaymentAddress(pa); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); retValue = CallRPC("getblockcount"); int nextBlockHeight = retValue.get_int() + 1; @@ -1726,7 +1726,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_shieldcoinbase_parameters) BOOST_AUTO_TEST_CASE(rpc_z_shieldcoinbase_internals) { SelectParams(CBaseChainParams::TESTNET); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1930,7 +1930,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters) BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals) { SelectParams(CBaseChainParams::TESTNET); - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); LOCK2(cs_main, pwalletMain->cs_wallet); diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index f795fa680..419398ae4 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -156,7 +156,7 @@ double benchmark_solve_equihash() CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << I; - auto params = Params(CBaseChainParams::MAIN).GetConsensus(); + const Consensus::Params& params = Params(CBaseChainParams::MAIN).GetConsensus(); unsigned int n = params.nEquihashN; unsigned int k = params.nEquihashK; eh_HashState eh_state; @@ -289,7 +289,7 @@ double benchmark_try_decrypt_sprout_notes(size_t nKeys) double benchmark_try_decrypt_sapling_notes(size_t nKeys) { // Set params - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); auto masterKey = GetTestMasterSaplingSpendingKey(); @@ -328,7 +328,7 @@ CWalletTx CreateSproutTxWithNoteData(const libzcash::SproutSpendingKey& sk) { double benchmark_increment_sprout_note_witnesses(size_t nTxs) { - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); CWallet wallet; SproutMerkleTree sproutTree; @@ -390,7 +390,7 @@ CWalletTx CreateSaplingTxWithNoteData(const Consensus::Params& consensusParams, double benchmark_increment_sapling_note_witnesses(size_t nTxs) { - auto consensusParams = Params().GetConsensus(); + const Consensus::Params& consensusParams = Params().GetConsensus(); CWallet wallet; SproutMerkleTree sproutTree;