Don't make "in" parameters look like "out"/"in-out" parameters: pass by ref to const instead of ref to non-const

This commit is contained in:
practicalswift 2020-12-06 00:14:17 +00:00
parent f35e4d906f
commit 12dcdaaa54
12 changed files with 16 additions and 16 deletions

View File

@ -914,7 +914,7 @@ std::set<BlockFilterType> g_enabled_filter_types;
std::terminate(); std::terminate();
}; };
bool AppInitBasicSetup(ArgsManager& args) bool AppInitBasicSetup(const ArgsManager& args)
{ {
// ********************************************************* Step 1: setup // ********************************************************* Step 1: setup
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -33,7 +33,7 @@ void InitParameterInteraction(ArgsManager& args);
* @note This can be done before daemonization. Do not call Shutdown() if this function fails. * @note This can be done before daemonization. Do not call Shutdown() if this function fails.
* @pre Parameters should be parsed and config file should be read. * @pre Parameters should be parsed and config file should be read.
*/ */
bool AppInitBasicSetup(ArgsManager& args); bool AppInitBasicSetup(const ArgsManager& args);
/** /**
* Initialization: parameter interaction. * Initialization: parameter interaction.
* @note This can be done before daemonization. Do not call Shutdown() if this function fails. * @note This can be done before daemonization. Do not call Shutdown() if this function fails.

View File

@ -112,7 +112,7 @@ bool GetUTXOStats(CCoinsView* view, CCoinsStats& stats, CoinStatsHashType hash_t
} }
// The legacy hash serializes the hashBlock // The legacy hash serializes the hashBlock
static void PrepareHash(CHashWriter& ss, CCoinsStats& stats) static void PrepareHash(CHashWriter& ss, const CCoinsStats& stats)
{ {
ss << stats.hashBlock; ss << stats.hashBlock;
} }

View File

@ -286,7 +286,7 @@ void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore,
SignTransactionResultToJSON(mtx, complete, coins, input_errors, result); SignTransactionResultToJSON(mtx, complete, coins, input_errors, result);
} }
void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, std::map<int, std::string>& input_errors, UniValue& result) void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, const std::map<int, std::string>& input_errors, UniValue& result)
{ {
// Make errors UniValue // Make errors UniValue
UniValue vErrors(UniValue::VARR); UniValue vErrors(UniValue::VARR);

View File

@ -25,7 +25,7 @@ class SigningProvider;
* @param result JSON object where signed transaction results accumulate * @param result JSON object where signed transaction results accumulate
*/ */
void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType, UniValue& result); void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType, UniValue& result);
void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, std::map<int, std::string>& input_errors, UniValue& result); void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, const std::map<int, std::string>& input_errors, UniValue& result);
/** /**
* Parse a prevtxs UniValue array and get the map of coins from it * Parse a prevtxs UniValue array and get the map of coins from it

View File

@ -66,7 +66,7 @@ public:
return setValid.contains(entry, erase); return setValid.contains(entry, erase);
} }
void Set(uint256& entry) void Set(const uint256& entry)
{ {
boost::unique_lock<boost::shared_mutex> lock(cs_sigcache); boost::unique_lock<boost::shared_mutex> lock(cs_sigcache);
setValid.insert(entry); setValid.insert(entry);

View File

@ -71,7 +71,7 @@ public:
} }
// Simulates connection failure so that we can test eviction of offline nodes // Simulates connection failure so that we can test eviction of offline nodes
void SimConnFail(CService& addr) void SimConnFail(const CService& addr)
{ {
LOCK(cs); LOCK(cs);
int64_t nLastSuccess = 1; int64_t nLastSuccess = 1;

View File

@ -75,7 +75,7 @@ public:
} }
}; };
static CDataStream AddrmanToStream(CAddrManSerializationMock& _addrman) static CDataStream AddrmanToStream(const CAddrManSerializationMock& _addrman)
{ {
CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION); CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION);
ssPeersIn << Params().MessageStart(); ssPeersIn << Params().MessageStart();

View File

@ -1860,7 +1860,7 @@ BOOST_AUTO_TEST_CASE(test_Capitalize)
BOOST_CHECK_EQUAL(Capitalize("\x00\xfe\xff"), "\x00\xfe\xff"); BOOST_CHECK_EQUAL(Capitalize("\x00\xfe\xff"), "\x00\xfe\xff");
} }
static std::string SpanToStr(Span<const char>& span) static std::string SpanToStr(const Span<const char>& span)
{ {
return std::string(span.begin(), span.end()); return std::string(span.begin(), span.end());
} }

View File

@ -505,13 +505,13 @@ private:
// Run the script checks using our policy flags. As this can be slow, we should // Run the script checks using our policy flags. As this can be slow, we should
// only invoke this on transactions that have otherwise passed policy checks. // only invoke this on transactions that have otherwise passed policy checks.
bool PolicyScriptChecks(ATMPArgs& args, Workspace& ws, PrecomputedTransactionData& txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main); bool PolicyScriptChecks(ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData& txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
// Re-run the script checks, using consensus flags, and try to cache the // Re-run the script checks, using consensus flags, and try to cache the
// result in the scriptcache. This should be done after // result in the scriptcache. This should be done after
// PolicyScriptChecks(). This requires that all inputs either be in our // PolicyScriptChecks(). This requires that all inputs either be in our
// utxo set or in the mempool. // utxo set or in the mempool.
bool ConsensusScriptChecks(ATMPArgs& args, Workspace& ws, PrecomputedTransactionData &txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main); bool ConsensusScriptChecks(ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData &txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
// Try to add the transaction to the mempool, removing any conflicts first. // Try to add the transaction to the mempool, removing any conflicts first.
// Returns true if the transaction is in the mempool after any size // Returns true if the transaction is in the mempool after any size
@ -921,7 +921,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
return true; return true;
} }
bool MemPoolAccept::PolicyScriptChecks(ATMPArgs& args, Workspace& ws, PrecomputedTransactionData& txdata) bool MemPoolAccept::PolicyScriptChecks(ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData& txdata)
{ {
const CTransaction& tx = *ws.m_ptx; const CTransaction& tx = *ws.m_ptx;
@ -948,7 +948,7 @@ bool MemPoolAccept::PolicyScriptChecks(ATMPArgs& args, Workspace& ws, Precompute
return true; return true;
} }
bool MemPoolAccept::ConsensusScriptChecks(ATMPArgs& args, Workspace& ws, PrecomputedTransactionData& txdata) bool MemPoolAccept::ConsensusScriptChecks(ATMPArgs& args, const Workspace& ws, PrecomputedTransactionData& txdata)
{ {
const CTransaction& tx = *ws.m_ptx; const CTransaction& tx = *ws.m_ptx;
const uint256& hash = ws.m_hash; const uint256& hash = ws.m_hash;

View File

@ -111,7 +111,7 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
return feebumper::Result::OK; return feebumper::Result::OK;
} }
static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, CCoinControl& coin_control) static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, const CCoinControl& coin_control)
{ {
// Get the fee rate of the original transaction. This is calculated from // Get the fee rate of the original transaction. This is calculated from
// the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the // the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the

View File

@ -77,7 +77,7 @@ WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
} }
//! Construct wallet tx status struct. //! Construct wallet tx status struct.
WalletTxStatus MakeWalletTxStatus(CWallet& wallet, const CWalletTx& wtx) WalletTxStatus MakeWalletTxStatus(const CWallet& wallet, const CWalletTx& wtx)
{ {
WalletTxStatus result; WalletTxStatus result;
result.block_height = wtx.m_confirm.block_height > 0 ? wtx.m_confirm.block_height : std::numeric_limits<int>::max(); result.block_height = wtx.m_confirm.block_height > 0 ? wtx.m_confirm.block_height : std::numeric_limits<int>::max();
@ -94,7 +94,7 @@ WalletTxStatus MakeWalletTxStatus(CWallet& wallet, const CWalletTx& wtx)
} }
//! Construct wallet TxOut struct. //! Construct wallet TxOut struct.
WalletTxOut MakeWalletTxOut(CWallet& wallet, WalletTxOut MakeWalletTxOut(const CWallet& wallet,
const CWalletTx& wtx, const CWalletTx& wtx,
int n, int n,
int depth) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) int depth) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)