Merge CCoinsViewCache's GetOutputFor and AccessCoin
They're doing the same thing now.
This commit is contained in:
parent
580b023092
commit
119e552f7c
4 changed files with 5 additions and 14 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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…
Add table
Reference in a new issue