Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
nyonson committed May 16, 2024
1 parent e10c969 commit 95a44cf
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions proxy/src/bin/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,27 @@ async fn proxy_conn(client: TcpStream) -> Result<(), bip324_proxy::Error> {

tokio::spawn(async move {
loop {
let res = read_v1(&mut client_reader).await;
match res {
Ok(msg) => {
println!(
"Read {} message from client, writing to remote.",
msg.command()
);
write_v1(&mut remote_writer, msg)
.await
.expect("write to remote");
}
Err(e) => {
panic!("unable to read from client {}", e);
}
}
let msg = read_v1(&mut client_reader).await.expect("read from client");
println!(
"Read {} message from client, writing to remote.",
msg.command()
);
write_v1(&mut remote_writer, msg)
.await
.expect("write to remote");
}
});

tokio::spawn(async move {
loop {
let res = read_v1(&mut remote_reader).await;
match res {
Ok(msg) => {
println!(
"Read {} message from remote, writing to client.",
msg.command()
);
write_v1(&mut client_writer, msg)
.await
.expect("write to client");
}
Err(e) => {
panic!("unable to read from remote {}", e);
}
}
let msg = read_v1(&mut remote_reader).await.expect("read from remote");
println!(
"Read {} message from remote, writing to client.",
msg.command()
);
write_v1(&mut client_writer, msg)
.await
.expect("write to client");
}
});

Expand Down

0 comments on commit 95a44cf

Please sign in to comment.