Browse Source

Merge CCoinsViewCache's GetOutputFor and AccessCoin

They're doing the same thing now.
0.15
Pieter Wuille 8 years ago
parent
commit
119e552f7c
  1. 9
      src/coins.cpp
  2. 2
      src/coins.h
  3. 4
      src/consensus/tx_verify.cpp
  4. 4
      src/policy/policy.cpp

9
src/coins.cpp

@ -213,13 +213,6 @@ unsigned int CCoinsViewCache::GetCacheSize() const {
return cacheCoins.size(); return cacheCoins.size();
} }
const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const
{
const Coin& coin = AccessCoin(input.prevout);
assert(!coin.IsPruned());
return coin.out;
}
CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const
{ {
if (tx.IsCoinBase()) if (tx.IsCoinBase())
@ -227,7 +220,7 @@ CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const
CAmount nResult = 0; CAmount nResult = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++) for (unsigned int i = 0; i < tx.vin.size(); i++)
nResult += GetOutputFor(tx.vin[i]).nValue; nResult += AccessCoin(tx.vin[i].prevout).out.nValue;
return nResult; return nResult;
} }

2
src/coins.h

@ -272,8 +272,6 @@ public:
//! Check whether all prevouts of the transaction are present in the UTXO set represented by this view //! Check whether all prevouts of the transaction are present in the UTXO set represented by this view
bool HaveInputs(const CTransaction& tx) const; bool HaveInputs(const CTransaction& tx) const;
const CTxOut &GetOutputFor(const CTxIn& input) const;
private: private:
CCoinsMap::iterator FetchCoins(const COutPoint &outpoint) const; CCoinsMap::iterator FetchCoins(const COutPoint &outpoint) const;

4
src/consensus/tx_verify.cpp

@ -126,7 +126,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
unsigned int nSigOps = 0; unsigned int nSigOps = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++) for (unsigned int i = 0; i < tx.vin.size(); i++)
{ {
const CTxOut &prevout = inputs.GetOutputFor(tx.vin[i]); const CTxOut &prevout = inputs.AccessCoin(tx.vin[i].prevout).out;
if (prevout.scriptPubKey.IsPayToScriptHash()) if (prevout.scriptPubKey.IsPayToScriptHash())
nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig); nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig);
} }
@ -146,7 +146,7 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
for (unsigned int i = 0; i < tx.vin.size(); i++) for (unsigned int i = 0; i < tx.vin.size(); i++)
{ {
const CTxOut &prevout = inputs.GetOutputFor(tx.vin[i]); const CTxOut &prevout = inputs.AccessCoin(tx.vin[i].prevout).out;
nSigOps += CountWitnessSigOps(tx.vin[i].scriptSig, prevout.scriptPubKey, &tx.vin[i].scriptWitness, flags); nSigOps += CountWitnessSigOps(tx.vin[i].scriptSig, prevout.scriptPubKey, &tx.vin[i].scriptWitness, flags);
} }
return nSigOps; return nSigOps;

4
src/policy/policy.cpp

@ -165,7 +165,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
for (unsigned int i = 0; i < tx.vin.size(); i++) for (unsigned int i = 0; i < tx.vin.size(); i++)
{ {
const CTxOut& prev = mapInputs.GetOutputFor(tx.vin[i]); const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;
std::vector<std::vector<unsigned char> > vSolutions; std::vector<std::vector<unsigned char> > vSolutions;
txnouttype whichType; txnouttype whichType;
@ -204,7 +204,7 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
if (tx.vin[i].scriptWitness.IsNull()) if (tx.vin[i].scriptWitness.IsNull())
continue; continue;
const CTxOut &prev = mapInputs.GetOutputFor(tx.vin[i]); const CTxOut &prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;
// get the scriptPubKey corresponding to this input: // get the scriptPubKey corresponding to this input:
CScript prevScript = prev.scriptPubKey; CScript prevScript = prev.scriptPubKey;

Loading…
Cancel
Save