[#kernel-BlockTreeDB]
= xref:kernel.adoc[kernel]::BlockTreeDB
:relfileprefix: ../
:mrdocs:

Access to the block database (blocks&sol;index&sol;)

== Synopsis

Declared in `&lt;node&sol;blockstorage&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class BlockTreeDB
    : public xref:CDBWrapper.adoc[CDBWrapper]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:CDBWrapper.adoc[CDBWrapper]`
| Wraps a LevelDB database, providing typed, serialized key&hyphen;value access&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CDBWrapper/operator_assign.adoc[`operator&equals;`]  [.small]#[deleted]#
| Copy assignment is disabled&period;
| xref:CDBWrapper/CompactFull.adoc[`CompactFull`] 
| Perform a blocking full compaction of the underlying LevelDB&period;
| xref:CDBWrapper/DynamicMemoryUsage.adoc[`DynamicMemoryUsage`] 
| Get an estimate of LevelDB memory usage (in bytes)&period;
| xref:CDBWrapper/Erase.adoc[`Erase`] 
| Removes the value stored under the given key&period;
| xref:CDBWrapper/EstimateSize.adoc[`EstimateSize`] 
| Estimates the on&hyphen;disk size of the entries in the given key range&period;
| xref:CDBWrapper/Exists.adoc[`Exists`] 
| Checks whether a value is stored under the given key&period;
| xref:CDBWrapper/GetProperty.adoc[`GetProperty`] 
| Return a LevelDB property value, if available&period;
| xref:CDBWrapper/IsEmpty.adoc[`IsEmpty`] 
| Return true if the database managed by this class contains no entries&period;
| xref:kernel/BlockTreeDB/LoadBlockIndexGuts.adoc[`LoadBlockIndexGuts`] 
| Load every block&hyphen;index entry from the database into memory&period;
| xref:CDBWrapper/NewIterator.adoc[`NewIterator`] 
| Creates a new iterator over the database&period; The caller owns the returned iterator&period;
| xref:CDBWrapper/Read.adoc[`Read`] 
| Reads and de&hyphen;obfuscates the value stored under the given key&period;
| xref:kernel/BlockTreeDB/ReadBlockFileInfo.adoc[`ReadBlockFileInfo`] 
| Read the stored info for one block file&period;
| xref:kernel/BlockTreeDB/ReadFlag.adoc[`ReadFlag`] 
| Read a named boolean flag&period;
| xref:kernel/BlockTreeDB/ReadLastBlockFile.adoc[`ReadLastBlockFile`] 
| Read the number of the last block file in use&period;
| xref:kernel/BlockTreeDB/ReadReindexing.adoc[`ReadReindexing`] 
| Read whether a reindex was in progress&period;
| xref:CDBWrapper/Write.adoc[`Write`] 
| Writes a single key&hyphen;value pair to the database&period;
| xref:CDBWrapper/WriteBatch.adoc[`WriteBatch`] 
| Atomically applies all writes and erases queued in a batch&period;
| xref:kernel/BlockTreeDB/WriteBatchSync.adoc[`WriteBatchSync`] 
| Atomically write block&hyphen;file info, the last&hyphen;file marker, and block&hyphen;index entries&period;
| xref:kernel/BlockTreeDB/WriteFlag.adoc[`WriteFlag`] 
| Persist a named boolean flag&period;
| xref:kernel/BlockTreeDB/WriteReindexing.adoc[`WriteReindexing`] 
| Persist whether a reindex is in progress&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CDBWrapper/HasKeyStartingWith.adoc[`HasKeyStartingWith`] 
| Probe an unopened database for a key prefix&period; Return true if a database at path exists and contains at least 1 entry beginning with prefix&semi; missing or empty databases return false, and database errors throw dbwrapper&lowbar;error&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:kernel/BlockTreeDB/2constructor.adoc[`BlockTreeDB`] 
| Inherit the CDBWrapper constructors to open the underlying database&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:dbwrapper_private/GetObfuscation.adoc[`&colon;&colon;dbwrapper&lowbar;private&colon;&colon;GetObfuscation`]
| Work around circular dependency, as well as for testing in dbwrapper&lowbar;tests&period; Database obfuscation should be considered an implementation detail of the specific database&period;
| xref:index_util/LookUpOne.adoc[`&colon;&colon;index&lowbar;util&colon;&colon;LookUpOne`]
| Look up a single index entry for a block, trying the height index then the hash index&period;
|===


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