mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
assumeutxo: Add documentation on dumptxoutset serialization format
This commit is contained in:
parent
c14ed7f384
commit
4d8e5edbaa
2 changed files with 13 additions and 0 deletions
|
@ -2702,6 +2702,13 @@ UniValue CreateUTXOSnapshot(
|
||||||
size_t written_coins_count{0};
|
size_t written_coins_count{0};
|
||||||
std::vector<std::pair<uint32_t, Coin>> coins;
|
std::vector<std::pair<uint32_t, Coin>> coins;
|
||||||
|
|
||||||
|
// To reduce space the serialization format of the snapshot avoids
|
||||||
|
// duplication of tx hashes. The code takes advantage of the guarantee by
|
||||||
|
// leveldb that keys are lexicographically sorted.
|
||||||
|
// In the coins vector we collect all coins that belong to a certain tx hash
|
||||||
|
// (key.hash) and when we have them all (key.hash != last_hash) we write
|
||||||
|
// them to file using the below lambda function.
|
||||||
|
// See also https://github.com/bitcoin/bitcoin/issues/25675
|
||||||
auto write_coins_to_file = [&](AutoFile& afile, const Txid& last_hash, const std::vector<std::pair<uint32_t, Coin>>& coins, size_t& written_coins_count) {
|
auto write_coins_to_file = [&](AutoFile& afile, const Txid& last_hash, const std::vector<std::pair<uint32_t, Coin>>& coins, size_t& written_coins_count) {
|
||||||
afile << last_hash;
|
afile << last_hash;
|
||||||
WriteCompactSize(afile, coins.size());
|
WriteCompactSize(afile, coins.size());
|
||||||
|
|
|
@ -885,6 +885,12 @@ private:
|
||||||
CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
|
CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
|
||||||
|
|
||||||
//! Internal helper for ActivateSnapshot().
|
//! Internal helper for ActivateSnapshot().
|
||||||
|
//!
|
||||||
|
//! De-serialization of a snapshot that is created with
|
||||||
|
//! CreateUTXOSnapshot() in rpc/blockchain.cpp.
|
||||||
|
//! To reduce space the serialization format of the snapshot avoids
|
||||||
|
//! duplication of tx hashes. The code takes advantage of the guarantee by
|
||||||
|
//! leveldb that keys are lexicographically sorted.
|
||||||
[[nodiscard]] bool PopulateAndValidateSnapshot(
|
[[nodiscard]] bool PopulateAndValidateSnapshot(
|
||||||
Chainstate& snapshot_chainstate,
|
Chainstate& snapshot_chainstate,
|
||||||
AutoFile& coins_file,
|
AutoFile& coins_file,
|
||||||
|
|
Loading…
Add table
Reference in a new issue