[#ChainstateManager-ActivateSnapshot]
= xref:ChainstateManager.adoc[ChainstateManager]::ActivateSnapshot
:relfileprefix: ../
:mrdocs:

Construct and activate a Chainstate on the basis of UTXO snapshot data&period;

== Synopsis

Declared in `&lt;validation&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
xref:util/Result.adoc[util::Result&lt;CBlockIndex*&gt;]
ActivateSnapshot(
    xref:AutoFile.adoc[AutoFile]& coins&lowbar;file,
    xref:node/SnapshotMetadata.adoc[node::SnapshotMetadata] const& metadata,
    bool in&lowbar;memory);
----

== Description

Steps&colon;

* Initialize an unused Chainstate&period;
* Load its `CoinsViews` contents from `coins&lowbar;file`&period;
* Verify that the hash of the resulting coinsdb matches the expected hash per assumeutxo chain parameters&period;
* Wait for our headers chain to include the base block of the snapshot&period;
* &quot;Fast forward&quot; the tip of the new chainstate to the base of the snapshot&period;
* Construct the new Chainstate and add it to m&lowbar;chainstates&period;

== Return Value

The base block index of the activated snapshot, or an error&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *coins&lowbar;file*
| Serialized UTXO snapshot to load the new chainstate from&period;
| *metadata*
| Metadata describing the snapshot file&period;
| *in&lowbar;memory*
| Whether the new chainstate&apos;s databases should be kept in memory only&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
