6 #ifndef FABCOIN_COINS_H 7 #define FABCOIN_COINS_H 20 #include <unordered_map> 58 template<
typename Stream>
66 template<
typename Stream>
122 typedef std::unordered_map<COutPoint, CCoinsCacheEntry, SaltedOutpointHasher>
CCoinsMap;
131 virtual bool GetKey(
COutPoint &key)
const = 0;
132 virtual bool GetValue(
Coin &coin)
const = 0;
133 virtual unsigned int GetValueSize()
const = 0;
135 virtual bool Valid()
const = 0;
136 virtual void Next() = 0;
152 virtual bool GetCoin(
const COutPoint &outpoint,
Coin &coin)
const;
155 virtual bool HaveCoin(
const COutPoint &outpoint)
const;
158 virtual uint256 GetBestBlock()
const;
164 virtual std::vector<uint256> GetHeadBlocks()
const;
168 virtual bool BatchWrite(CCoinsMap &mapCoins,
const uint256 &hashBlock);
189 bool GetCoin(
const COutPoint &outpoint,
Coin &coin)
const override;
190 bool HaveCoin(
const COutPoint &outpoint)
const override;
191 uint256 GetBestBlock()
const override;
192 std::vector<uint256> GetHeadBlocks()
const override;
194 bool BatchWrite(CCoinsMap &mapCoins,
const uint256 &hashBlock)
override;
196 size_t EstimateSize()
const override;
218 bool GetCoin(
const COutPoint &outpoint,
Coin &coin)
const override;
219 bool HaveCoin(
const COutPoint &outpoint)
const override;
220 uint256 GetBestBlock()
const override;
221 void SetBestBlock(
const uint256 &hashBlock);
222 bool BatchWrite(CCoinsMap &mapCoins,
const uint256 &hashBlock)
override;
224 throw std::logic_error(
"CCoinsViewCache cursor iteration not supported.");
232 bool HaveCoinInCache(
const COutPoint &outpoint)
const;
250 void AddCoin(
const COutPoint& outpoint,
Coin&& coin,
bool potential_overwrite);
257 bool SpendCoin(
const COutPoint &outpoint,
Coin* moveto =
nullptr);
273 unsigned int GetCacheSize()
const;
292 CCoinsMap::iterator FetchCoin(
const COutPoint &outpoint)
const;
314 #endif // FABCOIN_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
std::hash for asio::adress
assert(len-trim+(2 *lenIndices)<=WIDTH)
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 lius (Can be negative)
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
size_t operator()(const COutPoint &id) const
This must return size_t.
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.
An outpoint - a combination of a transaction hash and an index n into its vout.
size_t DynamicMemoryUsage() const
uint256 hashBlock
Make mutable so that we can "fill the cache" even from Get-methods declared as "const".
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check=false)
Utility function to add all of a transaction's outputs to a cache.
void Unserialize(Stream &s)
virtual ~CCoinsViewCursor()
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)
Coin(CTxOut &&outIn, int nHeightIn, bool fCoinBaseIn)
construct a Coin from a CTxOut and height/coinbase information.
Cursor for iterating over CoinsView state.