[#CoinsViews]
= CoinsViews
:mrdocs:

A convenience class for constructing the CCoinsView&ast; hierarchy used to facilitate access to the UTXO set&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CoinsViews;
----

== Description

This class consists of an arrangement of layered CCoinsView objects, preferring to store and retrieve coins in memory via `m&lowbar;cacheview` but ultimately falling back on cache misses to the canonical store of UTXOs on disk, `m&lowbar;dbview`&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CoinsViews/2constructor.adoc[`CoinsViews`]         [.small]#[constructor]#
| This constructor initializes CCoinsViewDB and CCoinsViewErrorCatcher instances, but it _does not_ create a CCoinsViewCache instance by default&period; This is done separately because the presence of the cache has implications on whether or not we&apos;re allowed to flush the cache&apos;s state to disk, which should not be done until the health of the database is verified&period;
| xref:CoinsViews/InitCache.adoc[`InitCache`] 
| Initialize the CCoinsViewCache member&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CoinsViews/m_cacheview.adoc[`m&lowbar;cacheview`] 
| This is the top layer of the cache hierarchy &hyphen; it keeps as many coins in memory as can fit per the dbcache setting&period;
| xref:CoinsViews/m_catcherview.adoc[`m&lowbar;catcherview`] 
| This view wraps access to the leveldb instance and handles read errors gracefully&period;
| xref:CoinsViews/m_connect_block_view.adoc[`m&lowbar;connect&lowbar;block&lowbar;view`] 
| Reused CoinsViewOverlay layered on top of m&lowbar;cacheview and passed to ConnectBlock()&period; Reset between calls and flushed only on success, so invalid blocks don&apos;t pollute the underlying cache&period;
| xref:CoinsViews/m_dbview.adoc[`m&lowbar;dbview`] 
| The lowest level of the CoinsViews cache hierarchy sits in a leveldb database on disk&period; All unspent coins reside in this store&period;
|===



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