fix: Docker support, WAL race condition, pusher panic fixes
- Add multi-stage Dockerfile with tini, non-root user, healthcheck - Fix SQLite WAL mode race between bal-server and bal-pusher (busy_timeout + retry) - Fix tbl_stats missing UNIQUE index for ON CONFLICT clause - Replace unwrap() panics in bal-pusher with graceful error handling - Add docker/entrypoint.sh with BAL_PUSHER_NETWORK support - cargo fmt across all files
This commit is contained in:
@@ -247,7 +247,13 @@ async fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(
|
||||
info!("db open {}", &cfg.db_file);
|
||||
|
||||
let sqlquery = "SELECT * FROM tbl_tx WHERE network = :network AND status = :status AND ( locktime < :bestblock_height OR locktime > :locktime_threshold AND locktime < :bestblock_time);";
|
||||
let query_tx = db.prepare(sqlquery).unwrap().into_iter();
|
||||
let query_tx = match db.prepare(sqlquery) {
|
||||
Ok(q) => q.into_iter(),
|
||||
Err(e) => {
|
||||
warn!("tbl_tx not ready yet (tables may not exist): {}", e);
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
trace!("query_tx: {}", sqlquery);
|
||||
trace!(":locktime_threshold: {}", LOCKTIME_THRESHOLD);
|
||||
trace!(":bestblock_time: {}", average_time);
|
||||
@@ -257,19 +263,28 @@ async fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(
|
||||
//let query_tx = db.prepare("SELECT * FROM tbl_tx where status = :status").unwrap().into_iter();
|
||||
let mut pushed_txs: Vec<String> = Vec::new();
|
||||
let mut invalid_txs: std::collections::HashMap<String, String> = HashMap::new();
|
||||
for row in query_tx
|
||||
.bind::<&[(_, Value)]>(
|
||||
&[
|
||||
(":locktime_threshold", (LOCKTIME_THRESHOLD as i64).into()),
|
||||
(":bestblock_time", (average_time as i64).into()),
|
||||
(":bestblock_height", (bcinfo.blocks as i64).into()),
|
||||
(":network", network_params.db_field.clone().into()),
|
||||
(":status", 0.into()),
|
||||
][..],
|
||||
)
|
||||
.unwrap()
|
||||
.map(|row| row.unwrap())
|
||||
{
|
||||
for row_result in match query_tx.bind::<&[(_, Value)]>(
|
||||
&[
|
||||
(":locktime_threshold", (LOCKTIME_THRESHOLD as i64).into()),
|
||||
(":bestblock_time", (average_time as i64).into()),
|
||||
(":bestblock_height", (bcinfo.blocks as i64).into()),
|
||||
(":network", network_params.db_field.clone().into()),
|
||||
(":status", 0.into()),
|
||||
][..],
|
||||
) {
|
||||
Ok(bound) => bound,
|
||||
Err(e) => {
|
||||
error!("Failed to bind query parameters: {}", e);
|
||||
return Ok(());
|
||||
}
|
||||
} {
|
||||
let row = match row_result {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
warn!("Failed to read row: {}", e);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let tx = row.read::<&str, _>("tx");
|
||||
let txid = row.read::<&str, _>("txid");
|
||||
let locktime = row.read::<i64, _>("locktime");
|
||||
|
||||
Reference in New Issue
Block a user