21 #include <unordered_map> 61 template<
typename Stream>
69 template<
typename Stream>
95 const uint64_t k0,
k1;
129 typedef std::unordered_map<COutPoint, CCoinsCacheEntry, SaltedOutpointHasher>
CCoinsMap;
138 virtual bool GetKey(
COutPoint &key)
const = 0;
139 virtual bool GetValue(
Coin &coin)
const = 0;
140 virtual unsigned int GetValueSize()
const = 0;
142 virtual bool Valid()
const = 0;
143 virtual void Next() = 0;
159 virtual bool GetCoin(
const COutPoint &outpoint,
Coin &coin)
const;
162 virtual bool HaveCoin(
const COutPoint &outpoint)
const;
165 virtual uint256 GetBestBlock()
const;
171 virtual std::vector<uint256> GetHeadBlocks()
const;
175 virtual bool BatchWrite(CCoinsMap &mapCoins,
const uint256 &hashBlock);
196 bool GetCoin(
const COutPoint &outpoint,
Coin &coin)
const override;
197 bool HaveCoin(
const COutPoint &outpoint)
const override;
198 uint256 GetBestBlock()
const override;
199 std::vector<uint256> GetHeadBlocks()
const override;
201 bool BatchWrite(CCoinsMap &mapCoins,
const uint256 &hashBlock)
override;
203 size_t EstimateSize()
const override;
230 bool GetCoin(
const COutPoint &outpoint,
Coin &coin)
const override;
231 bool HaveCoin(
const COutPoint &outpoint)
const override;
232 uint256 GetBestBlock()
const override;
233 void SetBestBlock(
const uint256 &hashBlock);
234 bool BatchWrite(CCoinsMap &mapCoins,
const uint256 &hashBlock)
override;
236 throw std::logic_error(
"CCoinsViewCache cursor iteration not supported.");
244 bool HaveCoinInCache(
const COutPoint &outpoint)
const;
262 void AddCoin(
const COutPoint& outpoint,
Coin&& coin,
bool potential_overwrite);
285 unsigned int GetCacheSize()
const;
304 CCoinsMap::iterator FetchCoin(
const COutPoint &outpoint)
const;
321 #endif // RAVEN_COINS_H
wrapper for CTxOut that provides a more compact serialization
CTxOut out
unspent transaction output
unsigned int fCoinBase
whether containing transaction was a coinbase
CCoinsViewCursor * Cursor() const override
Get a cursor to iterate over the whole state.
void Serialize(Stream &s) const
virtual ~CCoinsView()
As we use CCoinsViews polymorphically, have a virtual destructor.
int64_t CAmount
Amount in corbies (Can be negative)
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
Abstract view on the open txout dataset.
const Coin & AccessByTxid(const CCoinsViewCache &cache, const uint256 &txid)
Utility function to find any unspent output with a given txid.
CCoinsCacheEntry(Coin &&coin_)
std::unordered_map< COutPoint, CCoinsCacheEntry, SaltedOutpointHasher > CCoinsMap
An output of a transaction.
size_t operator()(const COutPoint &id) const
This must return size_t.
An outpoint - a combination of a transaction hash and an index n into its vout.
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, uint256 blockHash, bool check=false, CAssetsCache *assetsCache=nullptr, std::pair< std::string, CBlockAssetUndo > *undoAssetData=nullptr)
Utility function to add all of a transaction's outputs to a cache.
uint256 hashBlock
Make mutable so that we can "fill the cache" even from Get-methods declared as "const".
void Unserialize(Stream &s)
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
virtual ~CCoinsViewCursor()
size_t DynamicMemoryUsage() const
CCoinsViewCursor(const uint256 &hashBlockIn)
The basic transaction that is broadcasted on the network and contained in blocks. ...
CCoinsView backed by another CCoinsView.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
const uint256 & GetBestBlock() const
Get best block at the time this cursor was created.
T & REF(const T &val)
Used to bypass the rule against non-const reference to temporary where it makes sense with wrappers s...
Coin(const CTxOut &outIn, int nHeightIn, bool fCoinBaseIn)
uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256 &val, uint32_t extra)
bool IsAssetScript(int &nType, bool &fIsOwner, int &nStartingIndex) const
Coin(CTxOut &&outIn, int nHeightIn, bool fCoinBaseIn)
construct a Coin from a CTxOut and height/coinbase information.
Cursor for iterating over CoinsView state.