logs about current block

This commit is contained in:
bitcoinafterlife 2025-07-19 07:12:18 -04:00
parent afd21a5f2a
commit ca10284479
Signed by: bitcoinafterlife
GPG Key ID: FE756706E833E0D1
2 changed files with 10 additions and 6 deletions

View File

@ -9,8 +9,6 @@ use sqlite::{Value};
use serde::Serialize; use serde::Serialize;
use serde::Deserialize; use serde::Deserialize;
use std::env; use std::env;
use std::fs::OpenOptions;
use std::io::{ Write};
use log::{info,warn,error,trace,debug}; use log::{info,warn,error,trace,debug};
use zmq::{Context, Socket}; use zmq::{Context, Socket};
use std::str; use std::str;
@ -203,15 +201,21 @@ fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(), Err
//} //}
//let average_time = time_sum/11; //let average_time = time_sum/11;
info!("median time: {}",bcinfo.median_time); info!("median time: {}",bcinfo.median_time);
info!("blocks: {}",bcinfo.blocks);
debug!("best block hash: {}",bcinfo.best_block_hash);
let average_time = bcinfo.median_time; let average_time = bcinfo.median_time;
let db = sqlite::open(&cfg.db_file).unwrap(); let db = sqlite::open(&cfg.db_file).unwrap();
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();
trace!("query_tx: {}",sqlquery);
trace!(":locktime_threshold: {}", LOCKTIME_THRESHOLD ); trace!(":locktime_threshold: {}", LOCKTIME_THRESHOLD );
trace!(":bestblock_time: {}", average_time); trace!(":bestblock_time: {}", average_time);
trace!(":bestblock_height: {}", bcinfo.blocks); trace!(":bestblock_height: {}", bcinfo.blocks);
trace!(":network: {}", network_params.db_field.clone()); trace!(":network: {}", network_params.db_field.clone());
trace!(":status: {}", 0); trace!(":status: {}", 0);
let query_tx = db.prepare("SELECT * FROM tbl_tx WHERE network = :network AND status = :status AND ( locktime < :bestblock_height OR locktime > :locktime_threshold AND locktime < :bestblock_time);").unwrap().into_iter();
//let query_tx = db.prepare("SELECT * FROM tbl_tx where status = :status").unwrap().into_iter(); //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 pushed_txs:Vec<String> = Vec::new();
let mut invalid_txs: std::collections::HashMap<String, String> = HashMap::new(); let mut invalid_txs: std::collections::HashMap<String, String> = HashMap::new();
@ -428,7 +432,7 @@ fn main(){
debug!("ZMQ:GET TOPIC: {}", String::from_utf8(topic.clone()).expect("invalid topic")); debug!("ZMQ:GET TOPIC: {}", String::from_utf8(topic.clone()).expect("invalid topic"));
trace!("ZMQ:GET BODY: {}", hex::encode(&body)); trace!("ZMQ:GET BODY: {}", hex::encode(&body));
if topic == b"hashblock" { if topic == b"hashblock" {
info!("NEW BLOCK{}", hex::encode(&body)); info!("NEW BLOCK: {}", hex::encode(&body));
//let cfg = cfg.clone(); //let cfg = cfg.clone();
let _ = main_result(&cfg,network_params); let _ = main_result(&cfg,network_params);
} }

View File

@ -499,7 +499,7 @@ fn parse_env_netconfig<'a>(mut cfg_lock: MutexGuard<'a, MyConfig>, chain: &'a st
} }
} }
if let Ok(value) = env::var(format!("BAL_SERVER_{}_FIXE_FEE",chain.to_uppercase())) { if let Ok(value) = env::var(format!("BAL_SERVER_{}_FIXED_FEE",chain.to_uppercase())) {
if let Ok(v) = value.parse::<u64>(){ if let Ok(v) = value.parse::<u64>(){
cfg.fixed_fee = v; cfg.fixed_fee = v;
} }