5 #ifndef BITCOIN_INDEX_BASE_H 6 #define BITCOIN_INDEX_BASE_H 25 DB(
const fs::path &path,
size_t n_cache_size,
bool f_memory =
false,
26 bool f_wipe =
false,
bool f_obfuscate =
false);
92 virtual const char *
GetName()
const = 0;
115 #endif // BITCOIN_INDEX_BASE_H bool Commit()
Write the current index state (eg.
virtual bool Init()
Initialize internal state from the database and block index.
CThreadInterrupt m_interrupt
void ChainStateFlushed(const CBlockLocator &locator) override
Notifies listeners of the new active block chain on-disk.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
std::atomic< bool > m_synced
Whether the index is in sync with the main chain.
Batch of changes queued to be written to a CDBWrapper.
virtual bool Rewind(const CBlockIndex *current_tip, const CBlockIndex *new_tip)
Rewind index to an earlier chain tip during a chain reorg.
Implement this to subscribe to events generated in validation.
void Stop()
Stops the instance from staying in sync with blockchain updates.
std::thread m_thread_sync
virtual bool WriteBlock(const CBlock &block, const CBlockIndex *pindex)
Write update index entries for a newly connected block.
virtual ~BaseIndex()
Destructor interrupts sync thread if running and blocks until it exits.
Base class for indices of blockchain data.
void WriteBestBlock(CDBBatch &batch, const CBlockLocator &locator)
Write block locator of the chain that the txindex is in sync with.
std::atomic< const CBlockIndex * > m_best_block_index
The last block in the chain that the index is in sync with.
void Start()
Start initializes the sync state and registers the instance as a ValidationInterface so that it stays...
virtual bool CommitInternal(CDBBatch &batch)
Virtual method called internally by Commit that can be overridden to atomically commit more index sta...
A helper class for interruptible sleeps.
The block chain is a tree shaped structure starting with the genesis block at the root...
void BlockConnected(const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex) override
Notifies listeners of a block being connected.
void ThreadSync()
Sync the index with the block index starting from the current best block.
virtual const char * GetName() const =0
Get the name of the index for display in logs.
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.
virtual DB & GetDB() const =0
bool BlockUntilSyncedToCurrentChain() const
Blocks the current thread until the index is caught up to the current state of the block chain...