Construct and activate a Chainstate on the basis of UTXO snapshot data.

Synopsis

Declared in <validation.h>

[[nodiscard]]
util::Result<CBlockIndex*>
ActivateSnapshot(
    AutoFile& coins_file,
    node::SnapshotMetadata const& metadata,
    bool in_memory);

Description

Steps:

  • Initialize an unused Chainstate.

  • Load its CoinsViews contents from coins_file.

  • Verify that the hash of the resulting coinsdb matches the expected hash per assumeutxo chain parameters.

  • Wait for our headers chain to include the base block of the snapshot.

  • "Fast forward" the tip of the new chainstate to the base of the snapshot.

  • Construct the new Chainstate and add it to m_chainstates.

Return Value

The base block index of the activated snapshot, or an error.

Note

The return value should not be discarded.

Parameters

Name

Description

coins_file

Serialized UTXO snapshot to load the new chainstate from.

metadata

Metadata describing the snapshot file.

in_memory

Whether the new chainstate's databases should be kept in memory only.

Created with MrDocs