scan at each new block

This commit is contained in:
Sosthene 2024-06-25 11:23:15 +02:00 committed by Nicolas Cantu
parent 0647e255f9
commit e8ccf9ba93

View File

@ -235,7 +235,7 @@ async fn handle_zmq(zmq_url: String, electrum_url: String) {
let mut socket = zeromq::SubSocket::new(); let mut socket = zeromq::SubSocket::new();
socket.connect(&zmq_url).await.unwrap(); socket.connect(&zmq_url).await.unwrap();
socket.subscribe("rawtx").await.unwrap(); socket.subscribe("rawtx").await.unwrap();
// socket.subscribe("hashblock"); socket.subscribe("hashblock").await.unwrap();
loop { loop {
let core_msg = match socket.recv().await { let core_msg = match socket.recv().await {
Ok(m) => m, Ok(m) => m,
@ -260,7 +260,13 @@ async fn handle_zmq(zmq_url: String, electrum_url: String) {
continue; continue;
} }
}, },
Ok("hashblock") => todo!(), Ok("hashblock") => match scan_blocks(0, &electrum_url) {
Ok(_) => continue,
Err(e) => {
error!("{}", e);
continue;
}
},
_ => { _ => {
error!("Unexpected message in zmq"); error!("Unexpected message in zmq");
continue; continue;