Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/ord.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
17 changes: 13 additions & 4 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,23 +423,32 @@ 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;
} catch (const std::exception& e) {
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();
}

Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public Q_SLOTS:
QTimer* m_ord_sync_timer{nullptr};
std::unique_ptr<OrdManager> m_ord_manager;
bool m_ord_enabled{false};
bool m_ord_initial_update_complete{false};
std::optional<uint256> m_ord_last_update_tip;
#ifdef ENABLE_WALLET
PaymentServer* paymentServer{nullptr};
WalletController* m_wallet_controller{nullptr};
Expand Down
1 change: 1 addition & 0 deletions src/qt/ordmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down