* added client disconnect to client side code
* extra logging for demo
This commit is contained in:
@@ -44,16 +44,16 @@ async fn main() -> anyhow::Result<()> {
|
||||
let cli = Cli::parse();
|
||||
let mut client = create_client("/tmp/cosmos-broadcaster-mixnet-client-5".into()).await;
|
||||
let our_address = client.nym_address();
|
||||
println!("\nclient's nym address: {our_address}\n");
|
||||
println!("\nclient's nym address: {our_address}");
|
||||
|
||||
let sp_address = Recipient::try_from_base58_string("DP84PUbje5nMuz4HYSqpdPYHrb5WPjitTyufGubc6MNy.8YhkurLGEeSuRLxhKG5uY7Kz6M4YjytKpUNdZhmo8z56@HcH4JQ4oZ8M4mMXDj5UDAb4WpuhpTKGHBEsZ112mkPkm").unwrap();
|
||||
let sp_address = Recipient::try_from_base58_string("2f499xz7AfEmsdjd9zaxEVMZ4ed5pod2AqomZ74PSdTW.6heKJmwFZMw14Yz7CKF56iyKDaBBssmNWZJHErGg5jgm@HWdr8jgcr32cVGbjisjmwnVF4xrUBRGvbw86F9e3rFzS").unwrap();
|
||||
|
||||
match &cli.command {
|
||||
Some(Commands::OfflineSignTx(OfflineSignTx {
|
||||
mnemonic,
|
||||
nyx_token_receipient,
|
||||
})) => {
|
||||
println!("sending offline sign info to broadcaster via the mixnet: getting signing account sequence and chain ID");
|
||||
println!("\nsending offline sign info to broadcaster via the mixnet: getting signing account sequence and chain ID");
|
||||
let base58_tx_bytes = offline_sign(
|
||||
mnemonic.clone(),
|
||||
nyx_token_receipient.clone(),
|
||||
@@ -73,7 +73,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
let _n = stdin.read_line(&mut input).unwrap();
|
||||
|
||||
if input.starts_with('y') {
|
||||
println!("\nsending tx thru the mixnet to broadcaster service");
|
||||
println!("\nsending pre-signed tx through the mixnet to broadcaster service");
|
||||
let Ok((tx_hash, success)) = send_tx(base58_tx_bytes.unwrap(), sp_address, &mut client).await else { todo!() };
|
||||
println!(
|
||||
"tx hash returned from the broadcaster: {}\ntx was successful: {}",
|
||||
@@ -94,6 +94,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
println!("\ndisconnecting client");
|
||||
client.disconnect().await;
|
||||
println!("end");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -13,26 +13,27 @@ async fn main() -> anyhow::Result<()> {
|
||||
println!("\nservice's nym address: {our_address}");
|
||||
// the httpclient we will use to broadcast our signed tx to the Nyx blockchain
|
||||
let broadcaster = create_broadcaster().await;
|
||||
println!("listening for messages, press CTRL-C to exit");
|
||||
|
||||
loop {
|
||||
// listen out for incoming requests from mixnet, parse and match them
|
||||
let request: (RequestTypes, AnonymousSenderTag) =
|
||||
listen_and_parse_request(&mut client).await;
|
||||
// grab sender_tag from parsed request for anonymous replies
|
||||
// grab sender_tag from parsed request for anonymous replies
|
||||
let return_recipient: AnonymousSenderTag = request.1;
|
||||
match request.0 {
|
||||
RequestTypes::Sequence(request) => {
|
||||
println!(
|
||||
"\nincoming sequence request details:\nsigner address: {}",
|
||||
"\nincoming sequence request details:\nsigner address: {} \nquerying Nyx blockchain on behalf of requesting client",
|
||||
request.signer_address
|
||||
);
|
||||
// query Nyx chain for sequence information on behalf of request sender
|
||||
// query Nyx chain for sequence information on behalf of request sender
|
||||
let sequence: SequenceRequestResponse =
|
||||
get_sequence(broadcaster.clone(), request.signer_address)
|
||||
.await
|
||||
.unwrap();
|
||||
println!("sequence information query returned account number: {}, sequence:{}, chain id: {} \nsending response to requesting client via mixnet", sequence.account_number, sequence.sequence, sequence.chain_id);
|
||||
// send serialised sequence response back to request sender via mixnet
|
||||
println!("sequence information query returned account number: {}, sequence:{}, chain id: {} \nsending response to requesting client via mixnet", sequence.account_number, sequence.sequence, sequence.chain_id);
|
||||
// send serialised sequence response back to request sender via mixnet
|
||||
client
|
||||
.send_str_reply(return_recipient, &serde_json::to_string(&sequence).unwrap())
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user