Compare commits

..

No commits in common. "f7ccc295c463d35a91b04e3ca10136e32c595268" and "a85202b8b86a97e3cdb75548b8afc1b70cc14a9e" have entirely different histories.

View File

@ -15,7 +15,6 @@ use log::{info,debug,warn,error};
use zmq::{Context, Socket}; use zmq::{Context, Socket};
use std::str; use std::str;
use std::{thread, time::Duration}; use std::{thread, time::Duration};
use std::collections::HashMap;
//use byteorder::{LittleEndian, ReadBytesExt}; //use byteorder::{LittleEndian, ReadBytesExt};
//use std::io::Cursor; //use std::io::Cursor;
use hex; use hex;
@ -206,7 +205,7 @@ fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(), Err
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 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:Vec<String> = Vec::new();
for row in query_tx.bind::<&[(_, Value)]>(&[ for row in query_tx.bind::<&[(_, Value)]>(&[
(":locktime_threshold", (LOCKTIME_THRESHOLD as i64).into()), (":locktime_threshold", (LOCKTIME_THRESHOLD as i64).into()),
(":bestblock_time", (average_time as i64).into()), (":bestblock_time", (average_time as i64).into()),
@ -243,9 +242,7 @@ fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(), Err
file.write_all(data.as_bytes())?; file.write_all(data.as_bytes())?;
drop(file); drop(file);
warn!("Error: {}\n{}",err,txid); warn!("Error: {}\n{}",err,txid);
//store err in invalid_txs invalid_txs.push(txid.to_string());
invalid_txs.insert(txid.to_string(), err.to_string());
}, },
}; };
} }
@ -254,10 +251,7 @@ fn main_result(cfg: &MyConfig, network_params: &NetworkParams) -> Result<(), Err
let _ = db.execute(format!("UPDATE tbl_tx SET status = 1 WHERE txid in ('{}');",pushed_txs.join("','"))); let _ = db.execute(format!("UPDATE tbl_tx SET status = 1 WHERE txid in ('{}');",pushed_txs.join("','")));
} }
if invalid_txs.len() > 0 { if invalid_txs.len() > 0 {
for (txid,txerr) in &invalid_txs{ let _ = db.execute(format!("UPDATE tbl_tx SET status = 2 WHERE txid in ('{}');",invalid_txs.join("','")));
//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}'"));
}
} }
} }
Err(_)=>{ Err(_)=>{
@ -419,3 +413,4 @@ fn main(){
thread::sleep(Duration::from_millis(100)); // Sleep for 100ms thread::sleep(Duration::from_millis(100)); // Sleep for 100ms
} }
} }