14#include <validation.h>
35 LogPrintf(
"[snapshot] failed to open base blockhash file for writing: %s\n",
41 if (afile.fclose() != 0) {
42 LogPrintf(
"[snapshot] failed to close base blockhash file %s after writing\n",
52 LogPrintf(
"[snapshot] cannot read base blockhash: no chainstate dir "
60 LogPrintf(
"[snapshot] snapshot chainstate dir is malformed! no base blockhash file "
61 "exists at path %s. Try deleting %s and calling loadtxoutset again?\n",
70 LogPrintf(
"[snapshot] failed to open base blockhash file for reading: %s\n",
74 afile >> base_blockhash;
76 int64_t position = afile.tell();
77 afile.seek(0, SEEK_END);
78 if (position != afile.tell()) {
79 LogPrintf(
"[snapshot] warning: unexpected trailing data in %s\n", read_from_str);
81 return base_blockhash;
Non-refcounted RAII wrapper for FILE*.
std::optional< fs::path > StoragePath()
Chainstate stores and provides an API to update our local knowledge of the current best chain.
const std::optional< uint256 > m_from_snapshot_blockhash
The blockhash which is the base of the snapshot this chainstate was created from.
CCoinsViewDB & CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(
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.
static path u8path(const std::string &utf8_str)
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to a byte string.
FILE * fopen(const fs::path &p, const char *mode)
const fs::path SNAPSHOT_BLOCKHASH_FILENAME
The file in the snapshot chainstate dir which stores the base blockhash.
bool WriteSnapshotBaseBlockhash(Chainstate &snapshot_chainstate)
bool WriteSnapshotBaseBlockhash(Chainstate &snapshot_chainstate) EXCLUSIVE_LOCKS_REQUIRED(std::optional< uint256 > ReadSnapshotBaseBlockhash(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< uint256 > ReadSnapshotBaseBlockhash(fs::path chaindir)
std::optional< fs::path > FindSnapshotChainstateDir(const fs::path &data_dir)
Return a path to the snapshot-based chainstate dir, if one exists.