pusher fix
This commit is contained in:
		
							parent
							
								
									36edfcd073
								
							
						
					
					
						commit
						66f34cb29f
					
				| @ -11,7 +11,7 @@ use serde::Deserialize; | ||||
| use std::env; | ||||
| use std::fs::OpenOptions; | ||||
| use std::io::{ Write}; | ||||
| use log::{info,debug,warn,error}; | ||||
| use log::{info,warn,error,trace,debug}; | ||||
| use zmq::{Context, Socket}; | ||||
| use std::str; | ||||
| use std::{thread, time::Duration}; | ||||
| @ -117,7 +117,6 @@ fn get_cookie_filename(network: &NetworkParams) ->Result<String,Box<dyn StdError | ||||
|     }else{ | ||||
|         match env::var_os("HOME") { | ||||
|             Some(home) => { | ||||
|                 info!("some home {}",home.to_str().unwrap()); | ||||
|                 match home.to_str(){ | ||||
|                     Some(home_str) => { | ||||
|                         let cookie_file_path = format!("{}/.bitcoin/{}.cookie",home_str, network.dir_path); | ||||
| @ -206,7 +205,12 @@ fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(), Err | ||||
|             info!("median time: {}",bcinfo.median_time); | ||||
|             let average_time = bcinfo.median_time; | ||||
|             let db = sqlite::open(&cfg.db_file).unwrap(); | ||||
|             
 | ||||
|             trace!(":locktime_threshold: {}", LOCKTIME_THRESHOLD ); | ||||
|             trace!(":bestblock_time: {}", average_time); | ||||
|             trace!(":bestblock_height: {}", bcinfo.blocks); | ||||
|             trace!(":network: {}", network_params.db_field.clone()); | ||||
|             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 mut pushed_txs:Vec<String> = Vec::new(); | ||||
| @ -255,12 +259,16 @@ fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(), Err | ||||
|             } | ||||
|             
 | ||||
|             if pushed_txs.len() > 0 { | ||||
|                 let _ = db.execute(format!("UPDATE tbl_tx SET status = 1 WHERE txid in ('{}');",pushed_txs.join("','"))); | ||||
|                 let sql = format!("UPDATE tbl_tx SET status = 1 WHERE txid in ('{}');",pushed_txs.join("','")); | ||||
|                 trace!("sqlok: {}",&sql); | ||||
|                 let _ = db.execute(&sql); | ||||
|             } | ||||
|             if invalid_txs.len() > 0 { | ||||
|                 for (txid,txerr) in &invalid_txs{ | ||||
|                     //let _ = db.execute(format!("UPDATE tbl_tx SET status = 2 WHERE txid in ('{}'Yp);",invalid_txs.join("','")));
 | ||||
|                     let _ = db.execute(format!("UPDATE tbl_tx SET status = 2, push_err='{txerr}' WHERE txid = '{txid}'")); | ||||
|                     let sql = format!("UPDATE tbl_tx SET status = 2, push_err='{txerr}' WHERE txid = '{txid}'"); | ||||
|                     trace!("sqlerror: {}",&sql); | ||||
|                     let _ = db.execute(&sql); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -416,8 +424,10 @@ fn main(){ | ||||
|             let sequence = rdr.read_u32::<LittleEndian>().expect("Failed to read integer"); | ||||
|             sequence_str = sequence.to_string(); | ||||
|         }*/ | ||||
|         debug!("ZMQ:GET TOPIC: {}", String::from_utf8(topic.clone()).expect("invalid topic")); | ||||
|         trace!("ZMQ:GET BODY: {}", hex::encode(&body)); | ||||
|         if topic == b"hashblock" { | ||||
|             info!("NEW BLOCK{}", hex::encode(body));  
 | ||||
|             info!("NEW BLOCK{}", hex::encode(&body));  
 | ||||
|             //let cfg = cfg.clone();
 | ||||
|             let _ = main_result(&cfg,network_params); | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user