BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
Public Member Functions | List of all members
TxIndex::DB Class Reference

Access to the txindex database (indexes/txindex/) More...

Inheritance diagram for TxIndex::DB:
[legend]
Collaboration diagram for TxIndex::DB:
[legend]

Public Member Functions

 DB (size_t n_cache_size, bool f_memory=false, bool f_wipe=false)
 
bool ReadTxPos (const uint256 &txid, CDiskTxPos &pos) const
 Read the disk location of the transaction data with the given hash. More...
 
bool WriteTxs (const std::vector< std::pair< uint256, CDiskTxPos >> &v_pos)
 Write a batch of transaction positions to the DB. More...
 
bool MigrateData (CBlockTreeDB &block_tree_db, const CBlockLocator &best_locator)
 Migrate txindex data from the block tree DB, where it may be for older nodes that have not been upgraded yet to the new database. More...
 
- Public Member Functions inherited from BaseIndex::DB
 DB (const fs::path &path, size_t n_cache_size, bool f_memory=false, bool f_wipe=false, bool f_obfuscate=false)
 
bool ReadBestBlock (CBlockLocator &locator) const
 Read block locator of the chain that the txindex is in sync with. More...
 
bool WriteBestBlock (const CBlockLocator &locator)
 Write block locator of the chain that the txindex is in sync with. More...
 
- Public Member Functions inherited from CDBWrapper
 CDBWrapper (const fs::path &path, size_t nCacheSize, bool fMemory=false, bool fWipe=false, bool obfuscate=false)
 
 ~CDBWrapper ()
 
 CDBWrapper (const CDBWrapper &)=delete
 
CDBWrapperoperator= (const CDBWrapper &)=delete
 
template<typename K , typename V >
bool Read (const K &key, V &value) const
 
template<typename K , typename V >
bool Write (const K &key, const V &value, bool fSync=false)
 
template<typename K >
bool Exists (const K &key) const
 
template<typename K >
bool Erase (const K &key, bool fSync=false)
 
bool WriteBatch (CDBBatch &batch, bool fSync=false)
 
size_t DynamicMemoryUsage () const
 
bool Flush ()
 
bool Sync ()
 
CDBIteratorNewIterator ()
 
bool IsEmpty ()
 Return true if the database managed by this class contains no entries. More...
 
template<typename K >
size_t EstimateSize (const K &key_begin, const K &key_end) const
 
template<typename K >
void CompactRange (const K &key_begin, const K &key_end) const
 Compact a certain range of keys in the database. More...
 

Detailed Description

Access to the txindex database (indexes/txindex/)

The database stores a block locator of the chain the database is synced to so that the TxIndex 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.

Definition at line 53 of file txindex.cpp.

Constructor & Destructor Documentation

◆ DB()

TxIndex::DB::DB ( size_t  n_cache_size,
bool  f_memory = false,
bool  f_wipe = false 
)
explicit

Definition at line 70 of file txindex.cpp.

Member Function Documentation

◆ MigrateData()

bool TxIndex::DB::MigrateData ( CBlockTreeDB block_tree_db,
const CBlockLocator best_locator 
)

Migrate txindex data from the block tree DB, where it may be for older nodes that have not been upgraded yet to the new database.

Definition at line 106 of file txindex.cpp.

Here is the call graph for this function:

◆ ReadTxPos()

bool TxIndex::DB::ReadTxPos ( const uint256 txid,
CDiskTxPos pos 
) const

Read the disk location of the transaction data with the given hash.

Returns false if the transaction hash is not indexed.

Definition at line 74 of file txindex.cpp.

◆ WriteTxs()

bool TxIndex::DB::WriteTxs ( const std::vector< std::pair< uint256, CDiskTxPos >> &  v_pos)

Write a batch of transaction positions to the DB.

Definition at line 79 of file txindex.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following file: