6#ifndef BITCOIN_NODE_UTXO_SNAPSHOT_H
7#define BITCOIN_NODE_UTXO_SNAPSHOT_H
16#include <validation.h>
22 {
'u',
't',
'x',
'o', 0xff}};
48 const BlockHash &base_blockhash, uint64_t coins_count)
52 template <
typename Stream>
inline void Serialize(Stream &s)
const {
60 template <
typename Stream>
inline void Unserialize(Stream &s) {
65 throw std::ios_base::failure(
66 "Invalid UTXO set snapshot magic bytes. Please check if this "
67 "is indeed a snapshot file or if you are using an outdated "
75 throw std::ios_base::failure(
76 strprintf(
"Version of snapshot %s does not match any of the "
77 "supported versions.",
84 if (!std::equal(message.begin(), message.end(),
87 if (metadata_network) {
88 std::string network_string{
91 std::string node_network_string{
93 throw std::ios_base::failure(
94 strprintf(
"The network of the snapshot (%s) does not match "
95 "the network of this node (%s).",
96 network_string, node_network_string));
98 throw std::ios_base::failure(
99 "This snapshot has been created for an unrecognized "
100 "network. This could be a new testnet or possibly caused "
101 "by data corruption.");
std::string ChainTypeToString(ChainType chain)
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::optional< ChainType > GetNetworkForMagic(const CMessageHeader::MessageMagic &message)
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< 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.
std::optional< fs::path > FindSnapshotChainstateDir(const fs::path &data_dir)
Return a path to the snapshot-based chainstate dir, if one exists.
A BlockHash is a unqiue identifier for a block.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
static constexpr std::array< uint8_t, 5 > SNAPSHOT_MAGIC_BYTES