diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2023-11-25 12:10:52 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2024-03-12 09:30:42 -0300 |
commit | bcbd7eb8d40fbbd0e58c61acef087d65f2047036 (patch) | |
tree | 4e64d2e5e8c214aa5fddf48a0fed8c7fbb41e342 /src/index | |
parent | d14c7286b653ad09a5a196aa351b325f97db546b (diff) | |
download | bitcoin-bcbd7eb8d40fbbd0e58c61acef087d65f2047036.tar.xz |
bench: basic block filter index initial sync
Introduce benchmark for the block filter index sync.
And makes synchronous 'Sync()' mechanism accessible.
Diffstat (limited to 'src/index')
-rw-r--r-- | src/index/base.cpp | 4 | ||||
-rw-r--r-- | src/index/base.h | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/index/base.cpp b/src/index/base.cpp index 036292cd8a..5953fe2150 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -141,7 +141,7 @@ static const CBlockIndex* NextSyncBlock(const CBlockIndex* pindex_prev, CChain& return chain.Next(chain.FindFork(pindex_prev)); } -void BaseIndex::ThreadSync() +void BaseIndex::Sync() { const CBlockIndex* pindex = m_best_block_index.load(); if (!m_synced) { @@ -394,7 +394,7 @@ bool BaseIndex::StartBackgroundSync() { if (!m_init) throw std::logic_error("Error: Cannot start a non-initialized index"); - m_thread_sync = std::thread(&util::TraceThread, GetName(), [this] { ThreadSync(); }); + m_thread_sync = std::thread(&util::TraceThread, GetName(), [this] { Sync(); }); return true; } diff --git a/src/index/base.h b/src/index/base.h index 154061fb19..0eb1d9ca3b 100644 --- a/src/index/base.h +++ b/src/index/base.h @@ -78,13 +78,6 @@ private: std::thread m_thread_sync; CThreadInterrupt m_interrupt; - /// Sync the index with the block index starting from the current best block. - /// Intended to be run in its own thread, m_thread_sync, and can be - /// interrupted with m_interrupt. Once the index gets in sync, the m_synced - /// flag is set and the BlockConnected ValidationInterface callback takes - /// over and the sync thread exits. - void ThreadSync(); - /// Write the current index state (eg. chain block locator and subclass-specific items) to disk. /// /// Recommendations for error handling: @@ -152,9 +145,16 @@ public: /// validation interface so that it stays in sync with blockchain updates. [[nodiscard]] bool Init(); - /// Starts the initial sync process. + /// Starts the initial sync process on a background thread. [[nodiscard]] bool StartBackgroundSync(); + /// Sync the index with the block index starting from the current best block. + /// Intended to be run in its own thread, m_thread_sync, and can be + /// interrupted with m_interrupt. Once the index gets in sync, the m_synced + /// flag is set and the BlockConnected ValidationInterface callback takes + /// over and the sync thread exits. + void Sync(); + /// Stops the instance from staying in sync with blockchain updates. void Stop(); |