aboutsummaryrefslogtreecommitdiff
path: root/src/index/txindex.h
diff options
context:
space:
mode:
authorJim Posen <jimpo@coinbase.com>2017-12-08 10:42:31 -0800
committerJim Posen <jimpo@coinbase.com>2018-04-25 11:25:08 -0700
commit94b4f8bbb9e7e37f3057b47bf13a74de12b8e0cc (patch)
tree2fb5bb06c550a4370058c246dd11c3653d757c1b /src/index/txindex.h
parent34d68bf3a3db2b78c07180416949bbc58bd0b682 (diff)
downloadbitcoin-94b4f8bbb9e7e37f3057b47bf13a74de12b8e0cc.tar.xz
[index] TxIndex initial sync thread.
TxIndex starts up a background thread to get in sync with the block index before blocks are processed through the ValidationInterface.
Diffstat (limited to 'src/index/txindex.h')
-rw-r--r--src/index/txindex.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/index/txindex.h b/src/index/txindex.h
index 3d42a89635..35d58d5b65 100644
--- a/src/index/txindex.h
+++ b/src/index/txindex.h
@@ -30,12 +30,23 @@ private:
/// The last block in the chain that the TxIndex is in sync with.
std::atomic<const CBlockIndex*> m_best_block_index;
+ std::thread m_thread_sync;
+
/// Initialize internal state from the database and block index.
bool Init();
+ /// Sync the tx index with the block index starting from the current best
+ /// block. Intended to be run in its own thread, m_thread_sync. Once the
+ /// txindex gets in sync, the m_synced flag is set and the BlockConnected
+ /// ValidationInterface callback takes over and the sync thread exits.
+ void ThreadSync();
+
/// Write update index entries for a newly connected block.
bool WriteBlock(const CBlock& block, const CBlockIndex* pindex);
+ /// Write the current chain block locator to the DB.
+ bool WriteBestBlock(const CBlockIndex* block_index);
+
protected:
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex,
const std::vector<CTransactionRef>& txn_conflicted) override;