try connect without async

This commit is contained in:
Evan Feenstra
2022-06-10 10:34:18 -07:00
parent 7ee7ac071c
commit 8946a4cd8f
2 changed files with 25 additions and 11 deletions

View File

@@ -6,7 +6,21 @@ use vls_protocol::model::Secret;
use vls_protocol::{msgs, serde_bolt::WireString}; use vls_protocol::{msgs, serde_bolt::WireString};
use vls_proxy::util::{read_allowlist, read_integration_test_seed}; use vls_proxy::util::{read_allowlist, read_integration_test_seed};
pub async fn connect(tx: mpsc::Sender<ChannelRequest>) { pub fn blocking_connect(tx: mpsc::Sender<ChannelRequest>) {
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<ChannelRequest>) {
let init_msg_2 = crate::init::make_init_msg().expect("could make init msg"); let init_msg_2 = crate::init::make_init_msg().expect("could make init msg");
let (reply_tx, reply_rx) = oneshot::channel(); let (reply_tx, reply_rx) = oneshot::channel();
// Send a request to the MQTT handler to send to signer // Send a request to the MQTT handler to send to signer

View File

@@ -60,16 +60,16 @@ fn main() -> anyhow::Result<()> {
} else { } else {
let (tx, rx) = mpsc::channel(1000); let (tx, rx) = mpsc::channel(1000);
let (status_tx, _status_rx) = mpsc::channel(1000); let (status_tx, _status_rx) = mpsc::channel(1000);
let runtime = start_broker(rx, status_tx, "sphinx-1"); let _runtime = start_broker(rx, status_tx, "sphinx-1");
runtime.block_on(async { // runtime.block_on(async {
init::connect(tx.clone()).await; init::blocking_connect(tx.clone());
// listen to reqs from CLN // listen to reqs from CLN
let conn = UnixConnection::new(parent_fd); let conn = UnixConnection::new(parent_fd);
let client = UnixClient::new(conn); let client = UnixClient::new(conn);
// TODO pass status_rx into SignerLoop // TODO pass status_rx into SignerLoop
let mut signer_loop = SignerLoop::new(client, tx); let mut signer_loop = SignerLoop::new(client, tx);
signer_loop.start(); signer_loop.start();
}) // })
} }
Ok(()) Ok(())