[#BaseIndex-DB] = xref:BaseIndex.adoc[BaseIndex]::DB :relfileprefix: ../ :mrdocs: The database stores a block locator of the chain the database is synced to so that the index can efficiently determine the point it last stopped at. A locator is used instead of a simple hash of the chain tip because blocks and block index entries may not be flushed to disk until after this database is updated. == Synopsis Declared in `<index/base.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class DB : public xref:CDBWrapper.adoc[CDBWrapper] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:CDBWrapper.adoc[CDBWrapper]` | Wraps a LevelDB database, providing typed, serialized key‐value access. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BaseIndex/DB/2constructor.adoc[`DB`] [.small]#[constructor]# | Open the index database at the given path. | xref:BaseIndex/DB/2destructor.adoc[`~DB`] [.small]#[destructor]# [.small]#[virtual]# | Close the database and release its resources. | xref:CDBWrapper/operator_assign.adoc[`operator=`] [.small]#[deleted]# | Copy assignment is disabled. | xref:CDBWrapper/CompactFull.adoc[`CompactFull`] | Perform a blocking full compaction of the underlying LevelDB. | xref:CDBWrapper/DynamicMemoryUsage.adoc[`DynamicMemoryUsage`] | Get an estimate of LevelDB memory usage (in bytes). | xref:CDBWrapper/Erase.adoc[`Erase`] | Removes the value stored under the given key. | xref:CDBWrapper/EstimateSize.adoc[`EstimateSize`] | Estimates the on‐disk size of the entries in the given key range. | xref:CDBWrapper/Exists.adoc[`Exists`] | Checks whether a value is stored under the given key. | xref:CDBWrapper/GetProperty.adoc[`GetProperty`] | Return a LevelDB property value, if available. | xref:CDBWrapper/IsEmpty.adoc[`IsEmpty`] | Return true if the database managed by this class contains no entries. | xref:CDBWrapper/NewIterator.adoc[`NewIterator`] | Creates a new iterator over the database. The caller owns the returned iterator. | xref:CDBWrapper/Read.adoc[`Read`] | Reads and de‐obfuscates the value stored under the given key. | xref:BaseIndex/DB/ReadBestBlock.adoc[`ReadBestBlock`] [.small]#[virtual]# | Read block locator of the chain that the index is in sync with. Note, the returned locator will be empty if no record exists. | xref:CDBWrapper/Write.adoc[`Write`] | Writes a single key‐value pair to the database. | xref:CDBWrapper/WriteBatch.adoc[`WriteBatch`] | Atomically applies all writes and erases queued in a batch. | xref:BaseIndex/DB/WriteBestBlock.adoc[`WriteBestBlock`] [.small]#[virtual]# | Write block locator of the chain that the index is in sync with. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:CDBWrapper/HasKeyStartingWith.adoc[`HasKeyStartingWith`] | Probe an unopened database for a key prefix. Return true if a database at path exists and contains at least 1 entry beginning with prefix; missing or empty databases return false, and database errors throw dbwrapper_error. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:dbwrapper_private/GetObfuscation.adoc[`::dbwrapper_private::GetObfuscation`] | Work around circular dependency, as well as for testing in dbwrapper_tests. Database obfuscation should be considered an implementation detail of the specific database. | xref:index_util/LookUpOne.adoc[`::index_util::LookUpOne`] | Look up a single index entry for a block, trying the height index then the hash index. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#