Skip to content

Commit

Permalink
Made macOS performance better by removing unnecessary copying of Cons…
Browse files Browse the repository at this point in the history
…ensus::Params (#1144)
  • Loading branch information
psolstice authored Feb 19, 2022
1 parent 9301a5d commit d73a892
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/lelantus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ bool ConnectBlockLelantus(
if (fJustCheck)
return true;

auto& params = ::Params().GetConsensus();
const auto& params = ::Params().GetConsensus();
CHash256 hash;
std::vector<unsigned char> data(GroupElement::serialize_size);
bool updateHash = false;
Expand Down Expand Up @@ -1472,7 +1472,7 @@ void CLelantusState::GetAnonymitySet(
}

LelantusCoinGroupInfo &coinGroup = coinGroups[coinGroupID];
auto params = ::Params().GetConsensus();
const auto &params = ::Params().GetConsensus();
LOCK(cs_main);
int maxHeight = fStartLelantusBlacklist ? (chainActive.Height() - (ZC_MINT_CONFIRMATIONS - 1)) : (params.nLelantusFixesStartBlock - 1);

Expand Down
8 changes: 4 additions & 4 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ bool BlockAssembler::TestForBlock(CTxMemPool::txiter iter)
// Check transaction against sigma limits
if (tx.IsSigmaSpend()) {
CAmount spendAmount = sigma::GetSpendAmount(tx);
auto &params = chainparams.GetConsensus();
const auto &params = chainparams.GetConsensus();

if (tx.vin.size() > params.nMaxSigmaInputPerTransaction || spendAmount > params.nMaxValueSigmaSpendPerTransaction)
return false;
Expand All @@ -444,7 +444,7 @@ bool BlockAssembler::TestForBlock(CTxMemPool::txiter iter)
if(tx.IsLelantusJoinSplit()) {
CAmount spendAmount = lelantus::GetSpendTransparentAmount(tx);
size_t spendNumber = lelantus::GetSpendInputs(tx);
auto &params = chainparams.GetConsensus();
const auto &params = chainparams.GetConsensus();

if (spendNumber > params.nMaxLelantusInputPerTransaction || spendAmount > params.nMaxValueLelantusSpendPerTransaction)
return false;
Expand Down Expand Up @@ -476,7 +476,7 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
if(tx.IsLelantusJoinSplit()) {
CAmount spendAmount = lelantus::GetSpendTransparentAmount(tx);
size_t spendNumber = lelantus::GetSpendInputs(tx);
auto &params = chainparams.GetConsensus();
const auto &params = chainparams.GetConsensus();

if (spendAmount > params.nMaxValueLelantusSpendPerTransaction)
return;
Expand Down Expand Up @@ -801,7 +801,7 @@ void BlockAssembler::addPriorityTxs()
}

void BlockAssembler::FillFoundersReward(CMutableTransaction &coinbaseTx, bool fMTP) {
auto &params = chainparams.GetConsensus();
const auto &params = chainparams.GetConsensus();
CAmount coin = COIN / (fMTP ? params.nMTPRewardReduction : 1);

if (nHeight >= params.nSubsidyHalvingFirst && nHeight < params.nSubsidyHalvingFirst + params.nSubsidyHalvingInterval) {
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
txpools.getStemTxPool().size(),
txpools.getStemTxPool().DynamicMemoryUsage() / 1000);
int64_t nCurrTime = GetTimeMicros();
auto& consensus = Params().GetConsensus();
const auto& consensus = Params().GetConsensus();
int64_t nEmbargo = 1000000 * consensus.nDandelionEmbargoMinimum +
PoissonNextSend(nCurrTime, consensus.nDandelionEmbargoAvgAdd);
pfrom->insertDandelionEmbargo(tx.GetHash(), nEmbargo);
Expand Down
4 changes: 2 additions & 2 deletions src/sigma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ CAmount GetSpendAmount(const CTransaction& tx) {
}

bool CheckSigmaBlock(CValidationState &state, const CBlock& block) {
auto& consensus = ::Params().GetConsensus();
const auto& consensus = ::Params().GetConsensus();

size_t blockSpendsAmount = 0;
CAmount blockSpendsValue(0);
Expand Down Expand Up @@ -1096,7 +1096,7 @@ void CSigmaState::GetAnonymitySet(
return;

SigmaCoinGroupInfo coinGroup = coinGroups[denomAndId];
auto params = ::Params().GetConsensus();
const auto &params = ::Params().GetConsensus();
int maxHeight = fStartSigmaBlacklist ? (chainActive.Height() - (ZC_MINT_CONFIRMATIONS - 1)) : (params.nStartSigmaBlacklist - 1);

for (CBlockIndex *block = coinGroup.lastBlock;
Expand Down
2 changes: 1 addition & 1 deletion src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {

bool CBlockTreeDB::LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex)
{
auto consensusParams = Params().GetConsensus();
const auto &consensusParams = Params().GetConsensus();
std::unique_ptr<CDBIterator> pcursor(NewIterator());

pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256()));
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, bool fChe
return false;
}

auto params = ::Params().GetConsensus();
const auto &params = ::Params().GetConsensus();
if (tx.IsZerocoinSpend() || tx.IsZerocoinMint()) {
if (!isVerifyDB && nHeight >= params.nDisableZerocoinStartBlock)
return state.DoS(1, error("Zerocoin is disabled at this point"));
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/lelantusjoinsplitbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ CWalletTx LelantusJoinSplitBuilder::Build(
spendCoins.clear();
sigmaSpendCoins.clear();

auto& consensusParams = Params().GetConsensus();
const auto& consensusParams = Params().GetConsensus();
CAmount changeToMint = 0;

std::vector<sigma::CoinDenomination> denomChanges;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/sigmaspendbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ CAmount SigmaSpendBuilder::GetInputs(std::vector<std::unique_ptr<InputSigner>>&
selected.clear();
denomChanges.clear();

auto& consensusParams = Params().GetConsensus();
const auto& consensusParams = Params().GetConsensus();
std::list<CSigmaEntry> sigmaCoins = pwalletMain->GetAvailableCoins(coinControl);

if (!wallet.GetCoinsToSpend(required, selected, denomChanges, sigmaCoins,
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3258,7 +3258,7 @@ bool CWallet::GetCoinsToJoinSplit(
{

EnsureMintWalletAvailable();
Consensus::Params consensusParams = Params().GetConsensus();
const Consensus::Params &consensusParams = Params().GetConsensus();

if (required > consensusParams.nMaxValueLelantusSpendPerTransaction) {
throw std::invalid_argument(_("The required amount exceeds spend limit"));
Expand Down Expand Up @@ -5464,7 +5464,7 @@ std::pair<CAmount, unsigned int> CWallet::EstimateJoinSplitFee(

spendCoins.clear();
sigmaSpendCoins.clear();
auto &consensusParams = Params().GetConsensus();
const auto &consensusParams = Params().GetConsensus();
CAmount changeToMint = 0;

std::vector<sigma::CoinDenomination> denomChanges;
Expand Down

0 comments on commit d73a892

Please sign in to comment.