Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
utxo_snapshot.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2019 The Bitcoin Core 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_NODE_UTXO_SNAPSHOT_H
7#define BITCOIN_NODE_UTXO_SNAPSHOT_H
8
10#include <serialize.h>
11#include <util/fs.h>
12#include <validation.h>
13
14#include <optional>
15
16struct BlockHash;
17
18namespace node {
40
46const fs::path SNAPSHOT_BLOCKHASH_FILENAME{"base_blockhash"};
47
53
56std::optional<BlockHash> ReadSnapshotBaseBlockhash(const fs::path &chaindir)
58
61constexpr std::string_view SNAPSHOT_CHAINSTATE_SUFFIX = "_snapshot";
62
64std::optional<fs::path> FindSnapshotChainstateDir();
65
66} // namespace node
67
68#endif // BITCOIN_NODE_UTXO_SNAPSHOT_H
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Definition validation.h:699
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition fs.h:30
Metadata describing a serialized version of a UTXO set from which an assumeutxo Chainstate can be con...
SnapshotMetadata(const BlockHash &base_blockhash, uint64_t coins_count, uint64_t nchaintx)
uint64_t m_coins_count
The number of coins in the UTXO set contained in this snapshot.
BlockHash m_base_blockhash
The hash of the block that reflects the tip of the chain for the UTXO set contained in this snapshot.
SERIALIZE_METHODS(SnapshotMetadata, obj)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition cs_main.cpp:7
Definition init.h:28
const fs::path SNAPSHOT_BLOCKHASH_FILENAME
The file in the snapshot chainstate dir which stores the base blockhash.
bool WriteSnapshotBaseBlockhash(Chainstate &snapshot_chainstate)
std::optional< fs::path > FindSnapshotChainstateDir()
Return a path to the snapshot-based chainstate dir, if one exists.
std::optional< BlockHash > ReadSnapshotBaseBlockhash(const fs::path &chaindir)
bool WriteSnapshotBaseBlockhash(Chainstate &snapshot_chainstate) EXCLUSIVE_LOCKS_REQUIRED(std::optional< BlockHash > ReadSnapshotBaseBlockhash(const fs::path &chaindir) EXCLUSIVE_LOCKS_REQUIRED(constexpr std::string_view SNAPSHOT_CHAINSTATE_SUFFIX
Write out the blockhash of the snapshot base block that was used to construct this chainstate.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
#define READWRITE(...)
Definition serialize.h:166
A BlockHash is a unqiue identifier for a block.
Definition blockhash.h:13
#define EXCLUSIVE_LOCKS_REQUIRED(...)