BaseIndex::DB

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>

class DB
    : public CDBWrapper

Base Classes

NameDescription
CDBWrapperWraps a LevelDB database, providing typed, serialized key-value access.

Member Functions

NameDescription
DB [constructor]Open the index database at the given path.
~DB [destructor] [virtual]Close the database and release its resources.
operator= [deleted]Copy assignment is disabled.
CompactFull Perform a blocking full compaction of the underlying LevelDB.
DynamicMemoryUsage Get an estimate of LevelDB memory usage (in bytes).
Erase Removes the value stored under the given key.
EstimateSize Estimates the on-disk size of the entries in the given key range.
Exists Checks whether a value is stored under the given key.
GetProperty Return a LevelDB property value, if available.
IsEmpty Return true if the database managed by this class contains no entries.
NewIterator Creates a new iterator over the database. The caller owns the returned iterator.
Read Reads and de-obfuscates the value stored under the given key.
ReadBestBlock [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.
Write Writes a single key-value pair to the database.
WriteBatch Atomically applies all writes and erases queued in a batch.
WriteBestBlock [virtual]Write block locator of the chain that the index is in sync with.

Static Member Functions

NameDescription
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

NameDescription
::dbwrapper_private::GetObfuscationWork around circular dependency, as well as for testing in dbwrapper_tests. Database obfuscation should be considered an implementation detail of the specific database.
::index_util::LookUpOneLook up a single index entry for a block, trying the height index then the hash index.