feat(explorer): fuzzy search — filter the block list by partial hash/height
Add a fuzzy mode to the explorer search: a non-numeric, non-full-hash query now filters the list to cached blocks whose hash (or height text) contains the query substring, live as you type. Backed by a new ExplorerBlockCache::searchBlocks() (SQLite LIKE with escaped wildcards), memoized per query so it doesn't hit the DB every frame. Exact queries still navigate precisely: a block height re-anchors the list, and a full 64-char hash is resolved via RPC. Row clicks still open the detail modal. Empty results show "No matching cached blocks". Note: fuzzy matching covers cached (browsed/prefetched) blocks only — the daemon has no partial-hash index — while exact height/hash lookups reach any block. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct sqlite3;
|
||||
|
||||
@@ -41,6 +42,9 @@ public:
|
||||
const std::string& databasePath() const { return database_path_; }
|
||||
|
||||
std::map<int, ExplorerBlockSummary> loadRange(int minHeight, int maxHeight);
|
||||
// Fuzzy search over cached blocks: matches when the query is a substring of the height (as text)
|
||||
// or the block hash (case-insensitive). Returns newest-first, capped at `limit`.
|
||||
std::vector<ExplorerBlockSummary> searchBlocks(const std::string& query, int limit);
|
||||
bool storeBlock(const ExplorerBlockSummary& block);
|
||||
int cachedBlockCount();
|
||||
void clearBlocks();
|
||||
|
||||
Reference in New Issue
Block a user