64 std::copy(hash.
begin(), hash.
begin() + 20, coins[i].out.scriptPubKey.begin() + 3);
72 std::copy(hash.
begin(), hash.
begin() + 20, coins[i].out.scriptPubKey.begin() + 2);
79 std::copy(hash.
begin(), hash.
begin() + 20, coins[i].out.scriptPubKey.begin() + 2);
85 std::copy(hash.
begin(), hash.
begin() + 32, coins[i].out.scriptPubKey.begin() + 2);
91 std::copy(hash.
begin(), hash.
begin() + 32, coins[i].out.scriptPubKey.begin() + 2);
133 entry[i].entrytype = EntryType::NONE;
142class CoinsViewBottom final :
public CCoinsView
144 std::map<COutPoint, Coin> m_data;
147 std::optional<Coin> GetCoin(
const COutPoint& outpoint)
const final
149 if (
auto it{m_data.find(outpoint)}; it != m_data.end()) {
150 assert(!it->second.IsSpent());
156 uint256 GetBestBlock() const final {
return {}; }
157 std::vector<uint256> GetHeadBlocks() const final {
return {}; }
158 std::unique_ptr<CCoinsViewCursor> Cursor() const final {
return {}; }
159 size_t EstimateSize() const final {
return m_data.
size(); }
163 for (
auto it{
cursor.Begin()}; it !=
cursor.End(); it =
cursor.NextAndMaybeErase(*it)) {
164 if (it->second.IsDirty()) {
165 if (it->second.coin.IsSpent()) {
166 m_data.erase(it->first);
168 if (
cursor.WillErase(*it)) {
169 m_data[it->first] = std::move(it->second.coin);
171 m_data[it->first] = it->second.coin;
176 auto it2 = m_data.find(it->first);
177 if (it->second.coin.IsSpent()) {
181 assert(it->second.coin.out ==
it2->second.out);
182 assert(it->second.coin.fCoinBase ==
it2->second.fCoinBase);
183 assert(it->second.coin.nHeight ==
it2->second.nHeight);
195 static const PrecomputedData data;
200 std::vector<std::unique_ptr<CCoinsViewCache>>
caches;
214 if (entry.entrytype == EntryType::UNSPENT) {
215 return {{entry.coinidx, entry.height}};
216 }
else if (entry.entrytype == EntryType::SPENT) {
231 if (cache.entry[
outpointidx].entrytype != EntryType::NONE) {
233 cache.entry[
outpointidx].entrytype = EntryType::NONE;
264 if (!
sim.has_value()) {
298 if (!
sim.has_value()) {
315 Coin coin = data.coins[coinidx];
320 entry.entrytype = EntryType::UNSPENT;
321 entry.coinidx = coinidx;
329 Coin coin = data.coins[coinidx];
334 entry.entrytype = EntryType::UNSPENT;
335 entry.coinidx = coinidx;
357 if (!
sim.has_value()) {
389 caches.back()->SanityCheck();
430 for (
const auto& cache :
caches) {
431 cache->SanityCheck();
444 if (!
sim.has_value()) {
462 if (!
sim.has_value()) {
static constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
int64_t CAmount
Amount in satoshis (Can be negative)
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Abstract view on the open txout dataset.
An outpoint - a combination of a transaction hash and an index n into its vout.
A hasher class for SHA-256.
void Finalize(unsigned char hash[OUTPUT_SIZE])
CSHA256 & Write(const unsigned char *data, size_t len)
CTxOut out
unspent transaction output
uint32_t nHeight
at which height this containing transaction was included in the active block chain
unsigned int fCoinBase
whether containing transaction was a coinbase
CCoinsViewCache overlay that avoids populating/mutating parent cache layers on cache misses.
T ConsumeIntegralInRange(T min, T max)
static constexpr unsigned int size()
constexpr uint64_t GetUint64(int pos) const
constexpr unsigned char * begin()
void resize(size_type new_size)
static transaction_identifier FromUint256(const uint256 &id)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Cursor for iterating over the linked list of flagged entries in CCoinsViewCache.
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.