mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 22:43:06 +08:00
fix: db init command
This commit is contained in:
@@ -14,7 +14,7 @@ use chainhook_event_observer::chainhooks::types::{
|
||||
};
|
||||
use chainhook_event_observer::hord::db::{
|
||||
delete_data_in_hord_db, fetch_and_cache_blocks_in_hord_db,
|
||||
find_inscriptions_at_wached_outpoint, find_latest_compacted_block_known,
|
||||
find_inscriptions_at_wached_outpoint, find_latest_compacted_block_known, initialize_hord_db,
|
||||
open_readonly_hord_db_conn, open_readwrite_hord_db_conn,
|
||||
retrieve_satoshi_point_using_local_storage,
|
||||
};
|
||||
@@ -534,6 +534,8 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
|
||||
}
|
||||
};
|
||||
|
||||
let _ = initialize_hord_db(&config.expected_cache_path(), &ctx);
|
||||
|
||||
perform_hord_db_update(0, end_block, cmd.network_threads, &config, &ctx).await?;
|
||||
}
|
||||
DbCommand::Update(cmd) => {
|
||||
|
||||
@@ -247,10 +247,14 @@ impl CompactedBlock {
|
||||
|
||||
pub fn find_latest_compacted_block_known(hord_db_conn: &Connection) -> u32 {
|
||||
let args: &[&dyn ToSql] = &[];
|
||||
let mut stmt = hord_db_conn
|
||||
.prepare("SELECT id FROM blocks ORDER BY id DESC LIMIT 1")
|
||||
.unwrap();
|
||||
let mut rows = stmt.query(args).unwrap();
|
||||
let mut stmt = match hord_db_conn.prepare("SELECT id FROM blocks ORDER BY id DESC LIMIT 1") {
|
||||
Ok(stmt) => stmt,
|
||||
Err(_) => return 0,
|
||||
};
|
||||
let mut rows = match stmt.query(args) {
|
||||
Ok(rows) => rows,
|
||||
Err(_) => return 0,
|
||||
};
|
||||
while let Ok(Some(row)) = rows.next() {
|
||||
let id: u32 = row.get(0).unwrap();
|
||||
return id;
|
||||
|
||||
Reference in New Issue
Block a user