From d0867acb0e07ac63f03dcc555387f24322e8799e Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Sat, 19 Jul 2014 17:14:23 +0200 Subject: [PATCH] Use const CCoinsView's at some places. At some places where it is possible (e. g., CheckInputs), use a const version of CCoinsView instead of a non-const one. --- src/main.cpp | 6 +++--- src/main.h | 6 +++--- src/txmempool.cpp | 4 ++-- src/txmempool.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 947494ce625..1c9b3f861be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -644,7 +644,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) // 2. P2SH scripts with a crazy number of expensive // CHECKSIG/CHECKMULTISIG operations // -bool AreInputsStandard(const CTransaction& tx, CCoinsViewCache& mapInputs) +bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) { if (tx.IsCoinBase()) return true; // Coinbases don't use vin normally @@ -717,7 +717,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx) return nSigOps; } -unsigned int GetP2SHSigOpCount(const CTransaction& tx, CCoinsViewCache& inputs) +unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs) { if (tx.IsCoinBase()) return 0; @@ -1470,7 +1470,7 @@ bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned in return CScriptCheck(txFrom, txTo, nIn, flags, nHashType)(); } -bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, std::vector *pvChecks) +bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, std::vector *pvChecks) { if (!tx.IsCoinBase()) { diff --git a/src/main.h b/src/main.h index 886cac1507c..f93b78d8e50 100644 --- a/src/main.h +++ b/src/main.h @@ -265,7 +265,7 @@ int64_t GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF @param[in] mapInputs Map of previous transactions that have outputs we're spending @return True if all inputs (scriptSigs) use only standard transaction forms */ -bool AreInputsStandard(const CTransaction& tx, CCoinsViewCache& mapInputs); +bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs); /** Count ECDSA signature operations the old-fashioned (pre-0.6) way @return number of sigops this transaction's outputs will produce when spent @@ -279,13 +279,13 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx); @return maximum number of sigops required to validate this transaction's inputs @see CTransaction::FetchInputs */ -unsigned int GetP2SHSigOpCount(const CTransaction& tx, CCoinsViewCache& mapInputs); +unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& mapInputs); // Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) // This does not modify the UTXO set. If pvChecks is not NULL, script checks are pushed onto it // instead of being performed inline. -bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCache &view, bool fScriptChecks = true, +bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &view, bool fScriptChecks = true, unsigned int flags = STANDARD_SCRIPT_VERIFY_FLAGS, std::vector *pvChecks = NULL); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 3845a35b37f..f75e2212d55 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -484,7 +484,7 @@ void CTxMemPool::clear() ++nTransactionsUpdated; } -void CTxMemPool::check(CCoinsViewCache *pcoins) const +void CTxMemPool::check(const CCoinsViewCache *pcoins) const { if (!fSanityCheck) return; @@ -505,7 +505,7 @@ void CTxMemPool::check(CCoinsViewCache *pcoins) const const CTransaction& tx2 = it2->second.GetTx(); assert(tx2.vout.size() > txin.prevout.n && !tx2.vout[txin.prevout.n].IsNull()); } else { - CCoins &coins = pcoins->GetCoins(txin.prevout.hash); + const CCoins &coins = pcoins->GetCoins(txin.prevout.hash); assert(coins.IsAvailable(txin.prevout.n)); } // Check whether its inputs are marked in mapNextTx. diff --git a/src/txmempool.h b/src/txmempool.h index 074c355077e..d95c4d970b2 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -85,7 +85,7 @@ public: * all inputs are in the mapNextTx array). If sanity-checking is turned off, * check does nothing. */ - void check(CCoinsViewCache *pcoins) const; + void check(const CCoinsViewCache *pcoins) const; void setSanityCheck(bool _fSanityCheck) { fSanityCheck = _fSanityCheck; } bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry);