diff --git a/doc/ord.md b/doc/ord.md index c1ea4958b34c..da0d64ba4c02 100644 --- a/doc/ord.md +++ b/doc/ord.md @@ -21,6 +21,11 @@ After Bitcoin Core and its transaction index are synchronized, DogMode: installs it atomically. 4. Runs `ord index update` in the background with cookie authentication. +While Bitcoin Qt remains open, it checks the chain tip every 30 seconds and +reruns `ord index update` after a new block or a same-height reorganization. +The initial indexing message is shown once; later updates run quietly. An +indexing failure is reported in the GUI, and a restart also retries the update. + The Ord executable and index are stored below the network-specific Bitcoin data directory: diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index fd04f3298800..37fda0895e10 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -423,14 +423,17 @@ void BitcoinApplication::startOrd() maybeStartOrdIndex(); }); connect(m_ord_manager.get(), &OrdManager::indexComplete, window, [this] { - window->message(tr("Ord synchronized"), tr("The Ord index is synchronized. Use %1 in a terminal for Ordinal operations.").arg(m_ord_manager->executablePath()), CClientUIInterface::MSG_INFORMATION); + if (!m_ord_initial_update_complete) { + m_ord_initial_update_complete = true; + window->message(tr("Ord synchronized"), tr("The Ord index is synchronized. Use %1 in a terminal for Ordinal operations.").arg(m_ord_manager->executablePath()), CClientUIInterface::MSG_INFORMATION); + } }); m_ord_manager->start(); } void BitcoinApplication::maybeStartOrdIndex() { - if (!m_ord_manager || !m_ord_manager->isReady() || node().isInitialBlockDownload()) return; + if (!m_ord_manager || !m_ord_manager->isReady() || m_ord_manager->isIndexing() || node().isInitialBlockDownload()) return; try { const UniValue indexes{node().executeRpc("getindexinfo", UniValue{UniValue::VARR}, {})}; if (!indexes.exists("txindex") || !indexes["txindex"].exists("synced") || !indexes["txindex"]["synced"].get_bool()) return; @@ -438,8 +441,14 @@ void BitcoinApplication::maybeStartOrdIndex() qWarning() << "Unable to query txindex status for Ord:" << e.what(); return; } - if (m_ord_sync_timer) m_ord_sync_timer->stop(); - window->message(tr("Ord indexing"), tr("Bitcoin synchronization is complete. Ord is now building its index in the background."), CClientUIInterface::MSG_INFORMATION); + // An index update exits at the current tip. Run it again after a new block + // (or a same-height reorg) while Bitcoin Qt remains open. + const uint256 tip{node().getBestBlockHash()}; + if (m_ord_last_update_tip == tip) return; + m_ord_last_update_tip = tip; + if (!m_ord_initial_update_complete) { + window->message(tr("Ord indexing"), tr("Bitcoin synchronization is complete. Ord is now building its index in the background."), CClientUIInterface::MSG_INFORMATION); + } m_ord_manager->startIndex(); } diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h index 8f534f9c45a5..fa2230c8dd3e 100644 --- a/src/qt/bitcoin.h +++ b/src/qt/bitcoin.h @@ -103,6 +103,8 @@ public Q_SLOTS: QTimer* m_ord_sync_timer{nullptr}; std::unique_ptr m_ord_manager; bool m_ord_enabled{false}; + bool m_ord_initial_update_complete{false}; + std::optional m_ord_last_update_tip; #ifdef ENABLE_WALLET PaymentServer* paymentServer{nullptr}; WalletController* m_wallet_controller{nullptr}; diff --git a/src/qt/ordmanager.h b/src/qt/ordmanager.h index 623bcb22d0af..9e35a0bb9a73 100644 --- a/src/qt/ordmanager.h +++ b/src/qt/ordmanager.h @@ -27,6 +27,7 @@ class OrdManager : public QObject void startIndex(); void stop(); bool isReady() const { return !m_executable.isEmpty(); } + bool isIndexing() const { return m_index.isRunning(); } QString executablePath() const { return m_executable; } Q_SIGNALS: