Auto merge of #4784 - LarryRuane:auto-GetConsensus, r=str4d
performance: auto params = CChainParams::GetConsensus() Closes #4676 For consistency, this PR fixes all occurrences (most are in test code).
This commit is contained in:
commit
5bd2df92a5
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 &&
|
||||
|
|
|
@ -470,7 +470,7 @@ int printMetrics(size_t cols, bool mining)
|
|||
{
|
||||
LOCK2(cs_main, cs_metrics);
|
||||
boost::strict_lock_ptr<std::list<uint256>> u = trackedBlocks.synchronize();
|
||||
auto consensusParams = Params().GetConsensus();
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
auto tipHeight = chainActive.Height();
|
||||
|
||||
// Update orphans and calculate subsidies
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue