From 014a6dcfe1f5b2529024e8e0fa659e0c546f8652 Mon Sep 17 00:00:00 2001 From: erhant Date: Mon, 22 Jun 2026 18:37:07 +0300 Subject: [PATCH] feat: add status update checks for UI --- flake.lock | 8 ++++---- src/lez_indexer_module_impl.cpp | 19 +++++++++++++++++++ src/lez_indexer_module_impl.h | 4 ++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index f3197d7..e72553e 100644 --- a/flake.lock +++ b/flake.lock @@ -1348,11 +1348,11 @@ "rust-rapidsnark": "rust-rapidsnark" }, "locked": { - "lastModified": 1782123395, - "narHash": "sha256-vbfaImZIjSdou9KUyOT30vkhphTZiB3tIFlGGAuGjgY=", + "lastModified": 1782142589, + "narHash": "sha256-K5NtBontpPx1XqnX6jbEzPXSchaLbPlG9689W+C/ExA=", "ref": "erhant/fix-indexer-ffi", - "rev": "2c76fa959f6a3f3262f768d49411e5e177ad1b27", - "revCount": 2772, + "rev": "2a78b1b3d1b4080930c00ecf23b5c0e73cd646b8", + "revCount": 2773, "type": "git", "url": "https://github.com/logos-blockchain/logos-execution-zone" }, diff --git a/src/lez_indexer_module_impl.cpp b/src/lez_indexer_module_impl.cpp index 965ba6f..547afcc 100644 --- a/src/lez_indexer_module_impl.cpp +++ b/src/lez_indexer_module_impl.cpp @@ -226,6 +226,25 @@ std::string LezIndexerModuleImpl::getLastFinalizedBlockId() { return u64ToString(res.block_id); } +std::string LezIndexerModuleImpl::getStatus() { + if (!indexer_service_ffi) { + warn("getStatus", "indexer not started"); + return {}; + } + + // The FFI builds the status JSON itself (schema owned by indexer_core), so + // there is nothing to marshal — copy the C string out and free it. + char* json = ::query_status(handle(indexer_service_ffi)); + if (!json) { + warn("getStatus", "indexer FFI error"); + return {}; + } + + const std::string out(json); + ::free_cstring(json); + return out; +} + std::string LezIndexerModuleImpl::getTransactionsByAccount( const std::string& account_id, const std::string& offset, diff --git a/src/lez_indexer_module_impl.h b/src/lez_indexer_module_impl.h index 272e4b4..662de39 100644 --- a/src/lez_indexer_module_impl.h +++ b/src/lez_indexer_module_impl.h @@ -49,6 +49,10 @@ public: std::string getBlocks(const std::string& before, const std::string& limit); /// Tip block id as a bare decimal string. std::string getLastFinalizedBlockId(); + /// Current ingestion status as a compact JSON object so a UI can tell + /// "catching up" from "failed": { state (starting/syncing/caught_up/error), + /// indexedBlockId, lastError }. Empty string if the indexer isn't running. + std::string getStatus(); /// Transactions touching `account_id` (32-byte hex), paginated by decimal /// `offset`/`limit`. //