18 unsigned int nLastUsedByte = 0;
19 for (
unsigned int b = 0; 2+b*8 <
vout.size(); b++) {
21 for (
unsigned int i = 0; i < 8 && 2+b*8+i <
vout.size(); i++) {
22 if (!
vout[2+b*8+i].IsNull()) {
28 nLastUsedByte = b + 1;
32 nBytes += nLastUsedByte;
37 if (nPos >=
vout.size() ||
vout[nPos].IsNull())
73 CCoinsMap::iterator it =
cacheCoins.find(txid);
80 tmp.
swap(ret->second.coins);
81 if (ret->second.coins.IsPruned()) {
91 CCoinsMap::const_iterator it =
FetchCoins(txid);
93 coins = it->second.coins;
102 size_t cachedCoinUsage = 0;
106 ret.first->second.coins.Clear();
108 }
else if (ret.first->second.coins.IsPruned()) {
113 cachedCoinUsage = ret.first->second.coins.DynamicMemoryUsage();
123 ret.first->second.coins.Clear();
130 CCoinsMap::const_iterator it =
FetchCoins(txid);
134 return &it->second.coins;
139 CCoinsMap::const_iterator it =
FetchCoins(txid);
144 return (it !=
cacheCoins.end() && !it->second.coins.vout.empty());
148 CCoinsMap::const_iterator it =
cacheCoins.find(txid);
164 for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
166 CCoinsMap::iterator itUs =
cacheCoins.find(it->first);
194 itUs->second.coins.swap(it->second.coins);
200 CCoinsMap::iterator itOld = it++;
201 mapCoins.erase(itOld);
216 CCoinsMap::iterator it =
cacheCoins.find(hash);
217 if (it !=
cacheCoins.end() && it->second.flags == 0) {
240 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
249 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
262 inChainInputValue = 0;
265 double dResult = 0.0;
266 BOOST_FOREACH(
const CTxIn& txin, tx.
vin)
271 if (coins->
nHeight <= nHeight) {
273 inChainInputValue += coins->
vout[txin.
prevout.
n].nValue;
288 it->second.coins.Cleanup();
friend class CCoinsModifier
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock)
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
bool GetStats(CCoinsStats &stats) const
Calculate statistics about the unspent transaction output set.
size_t DynamicMemoryUsage() const
Calculate the size of the cache (in bytes)
static size_t DynamicUsage(const int8_t &v)
double ComputePriority(double dPriorityInputs, unsigned int nTxSize=0) const
CCoinsModifier(CCoinsViewCache &cache_, CCoinsMap::iterator it_, size_t usage)
bool IsAvailable(unsigned int nPos) const
check whether a particular output is still available
boost::unordered_map< uint256, CCoinsCacheEntry, CCoinsKeyHasher > CCoinsMap
bool HaveCoins(const uint256 &txid) const
const CTxOut & GetOutputFor(const CTxIn &input) const
virtual uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
CCoinsMap::iterator FetchCoins(const uint256 &txid)
void Cleanup()
remove spent outputs at the end of vout
size_t DynamicMemoryUsage() const
virtual bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
virtual bool GetStats(CCoinsStats &stats) const
Calculate statistics about the unspent transaction output set.
std::vector< CTxOut > vout
unspent transaction outputs; spent outputs are .IsNull(); spent outputs at the end of the array are d...
bool Spend(uint32_t nPos)
mark a vout spent
CCoinsViewCache(CCoinsView *baseIn)
void SetBackend(CCoinsView &viewIn)
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view...
virtual bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock)
virtual bool HaveCoins(const uint256 &txid) const
void SetBestBlock(const uint256 &hashBlock)
CCoinsModifier ModifyCoins(const uint256 &txid)
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock)
uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
void Uncache(const uint256 &txid)
const std::vector< CTxIn > vin
CCoinsViewBacked(CCoinsView *viewIn)
bool HaveCoinsInCache(const uint256 &txid) const
double GetPriority(const CTransaction &tx, int nHeight, CAmount &inChainInputValue) const
unsigned int GetCacheSize() const
Calculate the size of the cache (in number of transactions)
bool HaveCoins(const uint256 &txid) const
uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
void CalcMaskSize(unsigned int &nBytes, unsigned int &nNonzeroBytes) const
CCoinsModifier ModifyNewCoins(const uint256 &txid)
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
CAmount GetValueIn(const CTransaction &tx) const
int nHeight
at which height this transaction was included in the active block chain
const CCoins * AccessCoins(const uint256 &txid) const