[#ChainstateManager-ActivateSnapshot] = xref:ChainstateManager.adoc[ChainstateManager]::ActivateSnapshot :relfileprefix: ../ :mrdocs: Construct and activate a Chainstate on the basis of UTXO snapshot data. == Synopsis Declared in `<validation.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[nodiscard]] xref:util/Result.adoc[util::Result<CBlockIndex*>] ActivateSnapshot( xref:AutoFile.adoc[AutoFile]& coins_file, xref:node/SnapshotMetadata.adoc[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 https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^]. ==== == Parameters [cols="1,4"] |=== | 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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#