62 tx.
vin.emplace_back(outpoints[i]);
78 std::copy(hash.
begin(), hash.
begin() + 20, coins[i].out.scriptPubKey.begin() + 3);
86 std::copy(hash.
begin(), hash.
begin() + 20, coins[i].out.scriptPubKey.begin() + 2);
93 std::copy(hash.
begin(), hash.
begin() + 20, coins[i].out.scriptPubKey.begin() + 2);
99 std::copy(hash.
begin(), hash.
begin() + 32, coins[i].out.scriptPubKey.begin() + 2);
105 std::copy(hash.
begin(), hash.
begin() + 32, coins[i].out.scriptPubKey.begin() + 2);
147 entry[i].entrytype = EntryType::NONE;
158 std::map<COutPoint, Coin> m_data;
163 if (
auto it{m_data.find(outpoint)}; it != m_data.end()) {
164 assert(!it->second.IsSpent());
172 for (
auto it{
cursor.Begin()}; it !=
cursor.End(); it =
cursor.NextAndMaybeErase(*it)) {
173 if (it->second.IsDirty()) {
174 if (it->second.coin.IsSpent()) {
175 m_data.erase(it->first);
177 if (
cursor.WillErase(*it)) {
178 m_data[it->first] = std::move(it->second.coin);
180 m_data[it->first] = it->second.coin;
185 auto it2 = m_data.find(it->first);
186 if (it->second.coin.IsSpent()) {
190 assert(it->second.coin.out ==
it2->second.out);
191 assert(it->second.coin.fCoinBase ==
it2->second.fCoinBase);
192 assert(it->second.coin.nHeight ==
it2->second.nHeight);
201struct OverlayFetchScope
223 static const PrecomputedData
data;
228 std::vector<std::unique_ptr<CCoinsViewCache>>
caches;
244 if (entry.entrytype == EntryType::UNSPENT) {
245 return {{entry.coinidx, entry.height}};
246 }
else if (entry.entrytype == EntryType::SPENT) {
261 if (cache.entry[
outpointidx].entrytype != EntryType::NONE) {
263 cache.entry[
outpointidx].entrytype = EntryType::NONE;
271 return std::make_unique<OverlayFetchScope>(
overlay,
data.block);
302 if (!
sim.has_value()) {
336 if (!
sim.has_value()) {
358 entry.entrytype = EntryType::UNSPENT;
359 entry.coinidx = coinidx;
372 entry.entrytype = EntryType::UNSPENT;
373 entry.coinidx = coinidx;
395 if (!
sim.has_value()) {
429 caches.back()->SanityCheck();
481 cache->SanityCheck();
493 if (!
sim.has_value()) {
511 if (!
sim.has_value()) {
constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
int64_t CAmount
Amount in satoshis (Can be negative)
constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS
std::vector< CTransactionRef > vtx
CCoinsView that adds a memory cache for transactions to another CCoinsView.
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
bool fCoinBase
whether containing transaction was a coinbase
uint32_t nHeight
at which height this containing transaction was included in the active block chain
void BatchWrite(CoinsViewCacheCursor &cursor, const uint256 &) override
Do a bulk modification (multiple Coin changes + BestBlock change).
std::optional< Coin > GetCoin(const COutPoint &) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
CCoinsViewCache subclass that asynchronously fetches most block input prevouts in parallel during Con...
bool AllInputsConsumed() const noexcept
Verify that all parallel fetched input prevouts have been consumed.
T ConsumeIntegralInRange(T min, T max)
constexpr uint64_t GetUint64(int pos) const
constexpr unsigned char * begin()
void resize(size_type new_size)
static transaction_identifier FromUint256(const uint256 &id)
NotNull is intended to be used to denote that a smart pointer type can not hold a nullptr value.
std::vector< std::unique_ptr< CCoinsViewCache > > caches
Real CCoinsViewCache objects.
uint32_t current_height
Current height in the simulation.
CacheLevel sim_caches[MAX_CACHES+1]
Simulated cache data (sim_caches[0] matches bottom, sim_caches[i+1] matches caches[i]).
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
auto flush
Flush changes in top cache to the one below.
std::vector< std::unique_ptr< OverlayFetchScope > > fetch_scopes
Long-lived StartFetching guards, parallel to caches (entries are nullptr unless corresponding level i...
const auto make_fetch_scope
Helper creating a fetch scope for the top cache (which must be a CoinsViewOverlay).
CoinsViewBottom bottom
Dummy coinsview instance (base of the hierarchy).
auto lookup
Helper lookup function in the simulated cache stack.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.
Cursor for iterating over the linked list of flagged entries in CCoinsViewCache.
SeedRandomStateForTest(SeedRand::ZEROS)
FuzzedDataProvider provider
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
@ ZEROS
Seed with a compile time constant of zeros.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.