mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-06-13 16:19:01 +08:00
feat: always try to initialize tables when starting service
This commit is contained in:
@@ -441,6 +441,9 @@ async fn handle_command(opts: Opts, ctx: Context) -> Result<(), String> {
|
||||
if cmd.predicates_paths.len() > 0 && !cmd.start_http_api {
|
||||
config.http_api = PredicatesApi::Off;
|
||||
}
|
||||
|
||||
let _ = initialize_hord_db(&config.expected_cache_path(), &ctx);
|
||||
|
||||
let predicates = cmd
|
||||
.predicates_paths
|
||||
.iter()
|
||||
|
||||
@@ -68,36 +68,36 @@ pub fn initialize_hord_db(path: &PathBuf, ctx: &Context) -> Connection {
|
||||
)",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::error!(logger, "{}", e.to_string()));
|
||||
}
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE TABLE IF NOT EXISTS transfers (
|
||||
block_height INTEGER NOT NULL PRIMARY KEY
|
||||
)",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::error!(logger, "{}", e.to_string()));
|
||||
}
|
||||
ctx.try_log(|logger| slog::warn!(logger, "{}", e.to_string()));
|
||||
} else {
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE TABLE IF NOT EXISTS transfers (
|
||||
block_height INTEGER NOT NULL PRIMARY KEY
|
||||
)",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::warn!(logger, "{}", e.to_string()));
|
||||
}
|
||||
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS index_inscriptions_on_outpoint_to_watch ON inscriptions(outpoint_to_watch);",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::error!(logger, "{}", e.to_string()));
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS index_inscriptions_on_outpoint_to_watch ON inscriptions(outpoint_to_watch);",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::warn!(logger, "{}", e.to_string()));
|
||||
}
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS index_inscriptions_on_ordinal_number ON inscriptions(ordinal_number);",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::warn!(logger, "{}", e.to_string()));
|
||||
}
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS index_inscriptions_on_block_height ON inscriptions(block_height);",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::warn!(logger, "{}", e.to_string()));
|
||||
}
|
||||
}
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS index_inscriptions_on_ordinal_number ON inscriptions(ordinal_number);",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::error!(logger, "{}", e.to_string()));
|
||||
}
|
||||
if let Err(e) = conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS index_inscriptions_on_block_height ON inscriptions(block_height);",
|
||||
[],
|
||||
) {
|
||||
ctx.try_log(|logger| slog::error!(logger, "{}", e.to_string()));
|
||||
}
|
||||
|
||||
conn
|
||||
}
|
||||
|
||||
|
||||
@@ -41,10 +41,9 @@ use crate::{
|
||||
|
||||
use self::db::{
|
||||
find_inscription_with_id, find_latest_cursed_inscription_number_at_block_height,
|
||||
find_latest_inscription_number_at_block_height,
|
||||
parse_satpoint_to_watch, remove_entry_from_blocks,
|
||||
remove_entry_from_inscriptions, LazyBlock, LazyBlockTransaction, TraversalResult,
|
||||
WatchedSatpoint,
|
||||
find_latest_inscription_number_at_block_height, parse_satpoint_to_watch,
|
||||
remove_entry_from_blocks, remove_entry_from_inscriptions, LazyBlock, LazyBlockTransaction,
|
||||
TraversalResult, WatchedSatpoint,
|
||||
};
|
||||
use self::inscription::InscriptionParser;
|
||||
use self::ord::inscription_id::InscriptionId;
|
||||
|
||||
Reference in New Issue
Block a user