PRCYCoin  2.0.0.7rc1
P2P Digital Currency
coins.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_COINS_H
7 #define BITCOIN_COINS_H
8 
9 #include "compressor.h"
10 #include "memusage.h"
11 #include "consensus/consensus.h" // can be removed once policy/ established
12 #include "script/standard.h"
13 #include "serialize.h"
14 #include "uint256.h"
15 #include "undo.h"
16 
17 #include <assert.h>
18 #include <stdint.h>
19 
20 #include <boost/unordered_map.hpp>
21 
22 extern bool GetTransaction(const uint256& hash, CTransaction& tx, uint256& hashBlock, bool fAllowSlow, CBlockIndex* blockIndex);
23 
77 class CCoins
78 {
79 public:
81  bool fCoinBase;
82  bool fCoinStake;
83 
85  std::vector<CTxOut> vout;
86 
88  int nHeight;
89 
92  int nVersion;
93 
94  void FromTx(const CTransaction& tx, int nHeightIn)
95  {
96  fCoinBase = tx.IsCoinBase();
97  fCoinStake = tx.IsCoinStake();
98  vout = tx.vout;
99  nHeight = nHeightIn;
100  nVersion = tx.nVersion;
102  }
103 
105  CCoins(const CTransaction& tx, int nHeightIn)
106  {
107  FromTx(tx, nHeightIn);
108  }
109 
110  void Clear()
111  {
112  fCoinBase = false;
113  fCoinStake = false;
114  std::vector<CTxOut>().swap(vout);
115  nHeight = 0;
116  nVersion = 0;
117  }
118 
120  CCoins() : fCoinBase(false), fCoinStake(false), vout(0), nHeight(0), nVersion(0) {}
121 
123  void Cleanup()
124  {
125  while (vout.size() > 0 && vout.back().IsNull())
126  vout.pop_back();
127  if (vout.empty())
128  std::vector<CTxOut>().swap(vout);
129  }
130 
132  {
133  for (CTxOut& txout : vout) {
134  if (txout.scriptPubKey.IsUnspendable())
135  txout.SetNull();
136  }
137  Cleanup();
138  }
139 
140  void swap(CCoins& to)
141  {
142  std::swap(to.fCoinBase, fCoinBase);
143  std::swap(to.fCoinStake, fCoinStake);
144  to.vout.swap(vout);
145  std::swap(to.nHeight, nHeight);
146  std::swap(to.nVersion, nVersion);
147  }
148 
150  friend bool operator==(const CCoins& a, const CCoins& b)
151  {
152  // Empty CCoins objects are always equal.
153  if (a.IsPruned() && b.IsPruned())
154  return true;
155  return a.fCoinBase == b.fCoinBase &&
156  a.fCoinStake == b.fCoinStake &&
157  a.nHeight == b.nHeight &&
158  a.nVersion == b.nVersion &&
159  a.vout == b.vout;
160  }
161  friend bool operator!=(const CCoins& a, const CCoins& b)
162  {
163  return !(a == b);
164  }
165 
166  void CalcMaskSize(unsigned int& nBytes, unsigned int& nNonzeroBytes) const;
167 
168  bool IsCoinBase() const
169  {
170  return fCoinBase;
171  }
172 
173  bool IsCoinStake() const
174  {
175  return fCoinStake;
176  }
177 
178  unsigned int GetSerializeSize(int nType, int nVersion) const
179  {
180  unsigned int nSize = 0;
181  unsigned int nMaskSize = 0, nMaskCode = 0;
182  CalcMaskSize(nMaskSize, nMaskCode);
183  bool fFirst = vout.size() > 0 && !vout[0].IsNull();
184  bool fSecond = vout.size() > 1 && !vout[1].IsNull();
185  assert(fFirst || fSecond || nMaskCode);
186  unsigned int nCode = 8 * (nMaskCode - (fFirst || fSecond ? 0 : 1)) + (fCoinBase ? 1 : 0) + (fCoinStake ? 2 : 0) + (fFirst ? 4 : 0) + (fSecond ? 8 : 0);
187  // version
188  nSize += ::GetSerializeSize(VARINT(this->nVersion), nType, nVersion);
189  // size of header code
190  nSize += ::GetSerializeSize(VARINT(nCode), nType, nVersion);
191  // spentness bitmask
192  nSize += nMaskSize;
193  // txouts themself
194  for (unsigned int i = 0; i < vout.size(); i++)
195  if (!vout[i].IsNull())
196  nSize += ::GetSerializeSize(CTxOutCompressor(REF(vout[i])), nType, nVersion);
197  // height
198  nSize += ::GetSerializeSize(VARINT(nHeight), nType, nVersion);
199  return nSize;
200  }
201 
202  template <typename Stream>
203  void Serialize(Stream& s, int nType, int nVersion) const
204  {
205  unsigned int nMaskSize = 0, nMaskCode = 0;
206  CalcMaskSize(nMaskSize, nMaskCode);
207  bool fFirst = vout.size() > 0 && !vout[0].IsNull();
208  bool fSecond = vout.size() > 1 && !vout[1].IsNull();
209  assert(fFirst || fSecond || nMaskCode);
210  unsigned int nCode = 16 * (nMaskCode - (fFirst || fSecond ? 0 : 1)) + (fCoinBase ? 1 : 0) + (fCoinStake ? 2 : 0) + (fFirst ? 4 : 0) + (fSecond ? 8 : 0);
211  // version
212  ::Serialize(s, VARINT(this->nVersion), nType, nVersion);
213  // header code
214  ::Serialize(s, VARINT(nCode), nType, nVersion);
215  // spentness bitmask
216  for (unsigned int b = 0; b < nMaskSize; b++) {
217  unsigned char chAvail = 0;
218  for (unsigned int i = 0; i < 8 && 2 + b * 8 + i < vout.size(); i++)
219  if (!vout[2 + b * 8 + i].IsNull())
220  chAvail |= (1 << i);
221  ::Serialize(s, chAvail, nType, nVersion);
222  }
223  // txouts themself
224  for (unsigned int i = 0; i < vout.size(); i++) {
225  if (!vout[i].IsNull())
226  ::Serialize(s, CTxOutCompressor(REF(vout[i])), nType, nVersion);
227  }
228  // coinbase height
229  ::Serialize(s, VARINT(nHeight), nType, nVersion);
230  }
231 
232  template <typename Stream>
233  void Unserialize(Stream& s, int nType, int nVersion)
234  {
235  unsigned int nCode = 0;
236  // version
237  ::Unserialize(s, VARINT(this->nVersion), nType, nVersion);
238  // header code
239  ::Unserialize(s, VARINT(nCode), nType, nVersion);
240  fCoinBase = nCode & 1; //0001 - means coinbase
241  fCoinStake = (nCode & 2) != 0; //0010 coinstake
242  std::vector<bool> vAvail(2, false);
243  vAvail[0] = (nCode & 4) != 0; // 0100
244  vAvail[1] = (nCode & 8) != 0; // 1000
245  unsigned int nMaskCode = (nCode / 16) + ((nCode & 12) != 0 ? 0 : 1);
246  // spentness bitmask
247  while (nMaskCode > 0) {
248  unsigned char chAvail = 0;
249  ::Unserialize(s, chAvail, nType, nVersion);
250  for (unsigned int p = 0; p < 8; p++) {
251  bool f = (chAvail & (1 << p)) != 0;
252  vAvail.push_back(f);
253  }
254  if (chAvail != 0)
255  nMaskCode--;
256  }
257  // txouts themself
258  vout.assign(vAvail.size(), CTxOut());
259  for (unsigned int i = 0; i < vAvail.size(); i++) {
260  if (vAvail[i])
262  }
263  // coinbase height
264  ::Unserialize(s, VARINT(nHeight), nType, nVersion);
265  Cleanup();
266  }
267 
269  bool Spend(const COutPoint& out, CTxInUndo& undo);
270 
272  bool Spend(int nPos);
273 
275  bool IsAvailable(unsigned int nPos) const
276  {
277  return (nPos < vout.size() && !vout[nPos].IsNull());
278  }
279 
282  bool IsPruned() const
283  {
284  for (const CTxOut& out : vout)
285  if (!out.IsNull())
286  return false;
287  return true;
288  }
289 
290  size_t DynamicMemoryUsage() const {
291  size_t ret = memusage::DynamicUsage(vout);
292  for(const CTxOut &out : vout) {
293  ret += memusage::DynamicUsage(*static_cast<const CScriptBase*>(&out.scriptPubKey));
294  }
295  return ret;
296  }
297 };
298 
300 {
301 private:
303 
304 public:
305  CCoinsKeyHasher();
306 
312  size_t operator()(const uint256& key) const
313  {
314  return key.GetHash(salt);
315  }
316 };
317 
319  CCoins coins; // The actual cached data.
320  unsigned char flags;
321 
322  enum Flags {
323  DIRTY = (1 << 0), // This cache entry is potentially different from the version in the parent view.
324  FRESH = (1 << 1), // The parent view does not have this entry (or it is pruned).
325  };
326 
328 };
329 
330 typedef boost::unordered_map<uint256, CCoinsCacheEntry, CCoinsKeyHasher> CCoinsMap;
331 
332 struct CCoinsStats {
333  int nHeight;
335  uint64_t nTransactions;
337  uint64_t nSerializedSize;
340 
342 };
343 
344 
347 {
348 public:
350  virtual bool GetCoins(const uint256& txid, CCoins& coins) const;
351 
354  virtual bool HaveCoins(const uint256& txid) const;
355 
357  virtual uint256 GetBestBlock() const;
358 
361  virtual bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock);
362 
364  virtual bool GetStats(CCoinsStats& stats) const;
365 
367  virtual ~CCoinsView() {}
368 };
369 
370 
373 {
374 protected:
376 
377 public:
378  CCoinsViewBacked(CCoinsView* viewIn);
379  bool GetCoins(const uint256& txid, CCoins& coins) const;
380  bool HaveCoins(const uint256& txid) const;
381  uint256 GetBestBlock() const;
382  void SetBackend(CCoinsView& viewIn);
383  bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock);
384  bool GetStats(CCoinsStats& stats) const;
385 };
386 
387 class CCoinsViewCache;
388 
390 static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE |
392 
399 {
400 private:
402  CCoinsMap::iterator it;
403  size_t cachedCoinUsage; // Cached memory usage of the CCoins object before modification
404  CCoinsModifier(CCoinsViewCache& cache_, CCoinsMap::iterator it_, size_t usage);
405 
406 public:
407  CCoins* operator->() { return &it->second.coins; }
408  CCoins& operator*() { return it->second.coins; }
409  ~CCoinsModifier();
410  friend class CCoinsViewCache;
411 };
412 
415 {
416 protected:
417  /* Whether this cache has an active modifier. */
419 
426 
427  /* Cached dynamic memory usage for the inner CCoins objects. */
428  mutable size_t cachedCoinsUsage;
429 
430 public:
431  CCoinsViewCache(CCoinsView* baseIn);
433 
434  // Standard CCoinsView methods
435  bool GetCoins(const uint256& txid, CCoins& coins) const;
436  bool HaveCoins(const uint256& txid) const;
437  uint256 GetBestBlock() const;
438  void SetBestBlock(const uint256& hashBlock);
439  bool BatchWrite(CCoinsMap& mapCoins, const uint256& hashBlock);
440 
446  const CCoins* AccessCoins(const uint256& txid) const;
447 
453  CCoinsModifier ModifyCoins(const uint256& txid);
454 
460  bool Flush();
461 
463  unsigned int GetCacheSize() const;
464 
466  size_t DynamicMemoryUsage() const;
467 
469  bool HaveInputs(const CTransaction& tx) const;
470 
471  const CTxOut& GetOutputFor(const CTxIn& input) const;
472 
473  friend class CCoinsModifier;
474 
475 private:
476  CCoinsMap::iterator FetchCoins(const uint256& txid);
477  CCoinsMap::const_iterator FetchCoins(const uint256& txid) const;
478 };
479 
480 #endif // BITCOIN_COINS_H
CCoinsViewBacked::SetBackend
void SetBackend(CCoinsView &viewIn)
Definition: coins.cpp:77
CTxIn
An input of a transaction.
Definition: transaction.h:83
CCoinsKeyHasher::operator()
size_t operator()(const uint256 &key) const
This must return size_t.
Definition: coins.h:312
CCoinsKeyHasher::CCoinsKeyHasher
CCoinsKeyHasher()
Definition: coins.cpp:81
CCoinsViewCache::GetCacheSize
unsigned int GetCacheSize() const
Calculate the size of the cache (in number of transactions)
Definition: coins.cpp:231
CCoinsModifier::~CCoinsModifier
~CCoinsModifier()
Definition: coins.cpp:264
CCoins::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: coins.h:290
CCoinsViewCache::ModifyCoins
CCoinsModifier ModifyCoins(const uint256 &txid)
Return a modifiable reference to a CCoins.
Definition: coins.cpp:123
CCoins::Cleanup
void Cleanup()
remove spent outputs at the end of vout
Definition: coins.h:123
b
void const uint64_t * b
Definition: field_5x52_asm_impl.h:10
CCoinsViewBacked::GetStats
bool GetStats(CCoinsStats &stats) const
Calculate statistics about the unspent transaction output set.
Definition: coins.cpp:79
CCoinsModifier::CCoinsModifier
CCoinsModifier(CCoinsViewCache &cache_, CCoinsMap::iterator it_, size_t usage)
Definition: coins.cpp:258
CCoinsViewCache::CCoinsViewCache
CCoinsViewCache(CCoinsView *baseIn)
Definition: coins.cpp:83
CCoinsViewCache::GetOutputFor
const CTxOut & GetOutputFor(const CTxIn &input) const
Definition: coins.cpp:236
CCoinsModifier::cachedCoinUsage
size_t cachedCoinUsage
Definition: coins.h:403
uint256.h
CCoinsStats::nTransactions
uint64_t nTransactions
Definition: coins.h:335
CCoinsViewCache::cacheCoins
CCoinsMap cacheCoins
Definition: coins.h:425
CCoins::IsAvailable
bool IsAvailable(unsigned int nPos) const
check whether a particular output is still available
Definition: coins.h:275
CCoinsStats
Definition: coins.h:332
CCoins::FromTx
void FromTx(const CTransaction &tx, int nHeightIn)
Definition: coins.h:94
CCoins::nHeight
int nHeight
at which height this transaction was included in the active block chain
Definition: coins.h:88
CCoinsModifier::operator->
CCoins * operator->()
Definition: coins.h:407
CCoins::GetSerializeSize
unsigned int GetSerializeSize(int nType, int nVersion) const
Definition: coins.h:178
CCoins::operator==
friend bool operator==(const CCoins &a, const CCoins &b)
equality test
Definition: coins.h:150
LOCKTIME_VERIFY_SEQUENCE
@ LOCKTIME_VERIFY_SEQUENCE
Definition: consensus.h:27
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:269
CCoinsViewBacked::base
CCoinsView * base
Definition: coins.h:375
CCoinsViewCache::~CCoinsViewCache
~CCoinsViewCache()
Definition: coins.cpp:85
compressor.h
CCoinsView
Abstract view on the open txout dataset.
Definition: coins.h:346
CCoinsViewBacked::BatchWrite
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock)
Do a bulk modification (multiple CCoins changes + BestBlock change).
Definition: coins.cpp:78
CCoinsViewCache::hasModifier
bool hasModifier
Definition: coins.h:418
CCoinsView::BatchWrite
virtual bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock)
Do a bulk modification (multiple CCoins changes + BestBlock change).
Definition: coins.cpp:69
CTransaction::IsCoinBase
bool IsCoinBase() const
Definition: transaction.h:359
CCoinsView::GetCoins
virtual bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
Definition: coins.cpp:66
CCoins::vout
std::vector< CTxOut > vout
unspent transaction outputs; spent outputs are .IsNull(); spent outputs at the end of the array are d...
Definition: coins.h:85
CCoins::swap
void swap(CCoins &to)
Definition: coins.h:140
CCoinsCacheEntry::Flags
Flags
Definition: coins.h:322
CTxOut
An output of a transaction.
Definition: transaction.h:164
CCoins::IsCoinStake
bool IsCoinStake() const
Definition: coins.h:173
CCoinsStats::CCoinsStats
CCoinsStats()
Definition: coins.h:341
CCoinsStats::hashBlock
uint256 hashBlock
Definition: coins.h:334
CCoinsCacheEntry::CCoinsCacheEntry
CCoinsCacheEntry()
Definition: coins.h:327
GetTransaction
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow, CBlockIndex *blockIndex)
Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock.
Definition: main.cpp:2010
CCoinsViewCache::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Calculate the size of the cache (in bytes)
Definition: coins.cpp:90
VARINT
#define VARINT(obj)
Definition: serialize.h:366
CTransaction::vout
std::vector< CTxOut > vout
Definition: transaction.h:286
CCoinsModifier::it
CCoinsMap::iterator it
Definition: coins.h:402
CCoins::operator!=
friend bool operator!=(const CCoins &a, const CCoins &b)
Definition: coins.h:161
undo.h
consensus.h
CCoins::ClearUnspendable
void ClearUnspendable()
Definition: coins.h:131
CCoinsModifier
A reference to a mutable cache entry.
Definition: coins.h:398
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
CCoinsViewBacked::HaveCoins
bool HaveCoins(const uint256 &txid) const
Just check whether we have data for a given txid.
Definition: coins.cpp:75
standard.h
CCoinsCacheEntry::coins
CCoins coins
Definition: coins.h:319
CCoins::CCoins
CCoins()
empty constructor
Definition: coins.h:120
CCoinsCacheEntry::flags
unsigned char flags
Definition: coins.h:320
CCoinsViewCache::hashBlock
uint256 hashBlock
Make mutable so that we can "fill the cache" even from Get-methods declared as "const".
Definition: coins.h:424
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
CCoins::Unserialize
void Unserialize(Stream &s, int nType, int nVersion)
Definition: coins.h:233
CCoinsKeyHasher::salt
uint256 salt
Definition: coins.h:302
CTxOutCompressor
wrapper for CTxOut that provides a more compact serialization
Definition: compressor.h:106
CCoinsViewCache::AccessCoins
const CCoins * AccessCoins(const uint256 &txid) const
Return a pointer to CCoins in the cache, or NULL if not found.
Definition: coins.cpp:145
CCoinsViewBacked::CCoinsViewBacked
CCoinsViewBacked(CCoinsView *viewIn)
Definition: coins.cpp:73
CCoinsStats::nSerializedSize
uint64_t nSerializedSize
Definition: coins.h:337
CCoinsModifier::operator*
CCoins & operator*()
Definition: coins.h:408
CCoinsViewBacked::GetCoins
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
Definition: coins.cpp:74
CCoins::IsCoinBase
bool IsCoinBase() const
Definition: coins.h:168
CCoins::nVersion
int nVersion
version of the CTransaction; accesses to this value should probably check for nHeight as well,...
Definition: coins.h:92
prevector
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition: prevector.h:36
CCoinsStats::nHeight
int nHeight
Definition: coins.h:333
LOCKTIME_MEDIAN_TIME_PAST
@ LOCKTIME_MEDIAN_TIME_PAST
Definition: consensus.h:30
CCoinsViewCache::cachedCoinsUsage
size_t cachedCoinsUsage
Definition: coins.h:428
CCoinsViewCache::BatchWrite
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock)
Do a bulk modification (multiple CCoins changes + BestBlock change).
Definition: coins.cpp:177
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:414
CCoinsStats::nTransactionOutputs
uint64_t nTransactionOutputs
Definition: coins.h:336
CCoinsView::GetStats
virtual bool GetStats(CCoinsStats &stats) const
Calculate statistics about the unspent transaction output set.
Definition: coins.cpp:70
CCoinsViewBacked
CCoinsView backed by another CCoinsView.
Definition: coins.h:372
memusage.h
CCoinsViewCache::SetBestBlock
void SetBestBlock(const uint256 &hashBlock)
Definition: coins.cpp:172
CCoinsViewCache::HaveCoins
bool HaveCoins(const uint256 &txid) const
Just check whether we have data for a given txid.
Definition: coins.cpp:155
key
CKey key
Definition: bip38tooldialog.cpp:173
CCoinsStats::nTotalAmount
CAmount nTotalAmount
Definition: coins.h:339
CCoinsViewCache::HaveInputs
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view.
Definition: coins.cpp:243
CCoinsMap
boost::unordered_map< uint256, CCoinsCacheEntry, CCoinsKeyHasher > CCoinsMap
Definition: coins.h:330
CCoinsKeyHasher
Definition: coins.h:299
serialize.h
CCoins::fCoinStake
bool fCoinStake
Definition: coins.h:82
CCoinsStats::hashSerialized
uint256 hashSerialized
Definition: coins.h:338
CTxInUndo
Undo information for a CTxIn.
Definition: undo.h:20
CCoins
Definition: coins.h:77
CCoins::fCoinBase
bool fCoinBase
whether transaction is a coinbase
Definition: coins.h:81
CCoinsViewBacked::GetBestBlock
uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:76
CCoinsViewCache::GetBestBlock
uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:165
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:36
CCoins::Clear
void Clear()
Definition: coins.h:110
CTransaction::nVersion
const int32_t nVersion
Definition: transaction.h:284
CCoins::Spend
bool Spend(const COutPoint &out, CTxInUndo &undo)
mark an outpoint spent, and construct undo information
Definition: coins.cpp:38
CCoinsCacheEntry::FRESH
@ FRESH
Definition: coins.h:324
CCoinsCacheEntry::DIRTY
@ DIRTY
Definition: coins.h:323
CCoins::Serialize
void Serialize(Stream &s, int nType, int nVersion) const
Definition: coins.h:203
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:162
REF
T & REF(const T &val)
Used to bypass the rule against non-const reference to temporary where it makes sense with wrappers s...
Definition: serialize.h:34
CCoins::CCoins
CCoins(const CTransaction &tx, int nHeightIn)
construct a CCoins from a CTransaction, at a given height
Definition: coins.h:105
CCoinsView::HaveCoins
virtual bool HaveCoins(const uint256 &txid) const
Just check whether we have data for a given txid.
Definition: coins.cpp:67
CCoins::CalcMaskSize
void CalcMaskSize(unsigned int &nBytes, unsigned int &nNonzeroBytes) const
calculate number of bytes for the bitmask, and its number of non-zero bytes each bit in the bitmask r...
Definition: coins.cpp:19
CCoinsView::GetBestBlock
virtual uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
Definition: coins.cpp:68
CCoinsViewCache::FetchCoins
CCoinsMap::iterator FetchCoins(const uint256 &txid)
CCoinsModifier::cache
CCoinsViewCache & cache
Definition: coins.h:401
CCoinsViewCache::GetCoins
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
Definition: coins.cpp:113
CCoinsView::~CCoinsView
virtual ~CCoinsView()
As we use CCoinsViews polymorphically, have a virtual destructor.
Definition: coins.h:367
CCoinsCacheEntry
Definition: coins.h:318
CCoinsViewCache::Flush
bool Flush()
Push the modifications applied to this cache to its base.
Definition: coins.cpp:223
CCoins::IsPruned
bool IsPruned() const
check whether the entire CCoins is spent note that only !IsPruned() CCoins can be serialized
Definition: coins.h:282
CTransaction::IsCoinStake
bool IsCoinStake() const
Definition: transaction.cpp:143