diff --git a/broker/src/init.rs b/broker/src/init.rs index 5cc2744..d019526 100644 --- a/broker/src/init.rs +++ b/broker/src/init.rs @@ -6,7 +6,21 @@ use vls_protocol::model::Secret; use vls_protocol::{msgs, serde_bolt::WireString}; use vls_proxy::util::{read_allowlist, read_integration_test_seed}; -pub async fn connect(tx: mpsc::Sender) { +pub fn blocking_connect(tx: mpsc::Sender) { + let init_msg_2 = crate::init::make_init_msg().expect("could make init msg"); + let (reply_tx, reply_rx) = oneshot::channel(); + // Send a request to the MQTT handler to send to signer + let request = ChannelRequest { + message: init_msg_2, + reply_tx, + }; + let _ = tx.blocking_send(request); + let res = reply_rx.blocking_recv().expect("couldnt receive"); + let reply = parser::response_from_bytes(res.reply, 0).expect("could parse init receive"); + println!("REPLY {:?}", reply); +} + +pub async fn _connect(tx: mpsc::Sender) { let init_msg_2 = crate::init::make_init_msg().expect("could make init msg"); let (reply_tx, reply_rx) = oneshot::channel(); // Send a request to the MQTT handler to send to signer diff --git a/broker/src/main.rs b/broker/src/main.rs index 91f4db9..8b4eba1 100644 --- a/broker/src/main.rs +++ b/broker/src/main.rs @@ -60,16 +60,16 @@ fn main() -> anyhow::Result<()> { } else { let (tx, rx) = mpsc::channel(1000); let (status_tx, _status_rx) = mpsc::channel(1000); - let runtime = start_broker(rx, status_tx, "sphinx-1"); - runtime.block_on(async { - init::connect(tx.clone()).await; - // listen to reqs from CLN - let conn = UnixConnection::new(parent_fd); - let client = UnixClient::new(conn); - // TODO pass status_rx into SignerLoop - let mut signer_loop = SignerLoop::new(client, tx); - signer_loop.start(); - }) + let _runtime = start_broker(rx, status_tx, "sphinx-1"); + // runtime.block_on(async { + init::blocking_connect(tx.clone()); + // listen to reqs from CLN + let conn = UnixConnection::new(parent_fd); + let client = UnixClient::new(conn); + // TODO pass status_rx into SignerLoop + let mut signer_loop = SignerLoop::new(client, tx); + signer_loop.start(); + // }) } Ok(())