From 1c27f751c30196e2c421ae420dacbc4ff25f0fc7 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 13 Jun 2024 05:52:48 +0200 Subject: jsonrpc: spread out comments and clean up --- p2p/examples/monitor/Cargo.lock | 10 +++++----- p2p/examples/monitor/src/client.rs | 3 ++- p2p/examples/monitor/src/main.rs | 23 +++++++++++++---------- p2p/examples/tokio-example/Cargo.lock | 6 +++--- 4 files changed, 23 insertions(+), 19 deletions(-) (limited to 'p2p/examples') diff --git a/p2p/examples/monitor/Cargo.lock b/p2p/examples/monitor/Cargo.lock index cfb7934..d400d59 100644 --- a/p2p/examples/monitor/Cargo.lock +++ b/p2p/examples/monitor/Cargo.lock @@ -1193,7 +1193,7 @@ dependencies = [ [[package]] name = "karyon_core" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel 2.3.1", "async-process", @@ -1212,7 +1212,7 @@ dependencies = [ [[package]] name = "karyon_jsonrpc" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel 2.3.1", "async-trait", @@ -1230,7 +1230,7 @@ dependencies = [ [[package]] name = "karyon_jsonrpc_macro" -version = "0.1.0" +version = "0.1.1" dependencies = [ "proc-macro2", "quote", @@ -1240,7 +1240,7 @@ dependencies = [ [[package]] name = "karyon_net" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel 2.3.1", "async-trait", @@ -1259,7 +1259,7 @@ dependencies = [ [[package]] name = "karyon_p2p" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel 2.3.1", "async-trait", diff --git a/p2p/examples/monitor/src/client.rs b/p2p/examples/monitor/src/client.rs index d4970eb..b81c286 100644 --- a/p2p/examples/monitor/src/client.rs +++ b/p2p/examples/monitor/src/client.rs @@ -43,6 +43,7 @@ fn main() { loop { let _event = sub2.recv().await.expect("Receive peer pool event"); } - }).await; + }) + .await; }); } diff --git a/p2p/examples/monitor/src/main.rs b/p2p/examples/monitor/src/main.rs index 636d652..c57d06c 100644 --- a/p2p/examples/monitor/src/main.rs +++ b/p2p/examples/monitor/src/main.rs @@ -9,7 +9,9 @@ use serde::{Deserialize, Serialize}; use smol::{channel, lock::Mutex, Executor}; use karyon_core::async_util::{CondWait, TaskGroup, TaskResult}; -use karyon_jsonrpc::{rpc_impl, rpc_pubsub_impl, ArcChannel, Server, Subscription, SubscriptionID}; +use karyon_jsonrpc::{ + message::SubscriptionID, rpc_impl, rpc_pubsub_impl, Channel, Server, Subscription, +}; use karyon_p2p::{ endpoint::{Endpoint, Port}, keypair::{KeyPair, KeyPairType}, @@ -158,12 +160,12 @@ impl MonitorRPC { impl MonitorRPC { async fn conn_subscribe( &self, - chan: ArcChannel, + chan: Arc, method: String, _params: serde_json::Value, ) -> karyon_jsonrpc::Result { let sub = chan.new_subscription(&method).await; - let sub_id = sub.id.clone(); + let sub_id = sub.id; let cond_wait = self.conn_event_condvar.clone(); let buffer = self.conn_event_buffer.clone(); @@ -175,12 +177,12 @@ impl MonitorRPC { async fn peer_pool_subscribe( &self, - chan: ArcChannel, + chan: Arc, method: String, _params: serde_json::Value, ) -> karyon_jsonrpc::Result { let sub = chan.new_subscription(&method).await; - let sub_id = sub.id.clone(); + let sub_id = sub.id; let cond_wait = self.pp_event_condvar.clone(); let buffer = self.pp_event_buffer.clone(); @@ -192,12 +194,12 @@ impl MonitorRPC { async fn discovery_subscribe( &self, - chan: ArcChannel, + chan: Arc, method: String, _params: serde_json::Value, ) -> karyon_jsonrpc::Result { let sub = chan.new_subscription(&method).await; - let sub_id = sub.id.clone(); + let sub_id = sub.id; let cond_wait = self.discv_event_condvar.clone(); let buffer = self.discv_event_buffer.clone(); @@ -209,7 +211,7 @@ impl MonitorRPC { async fn conn_unsubscribe( &self, - chan: ArcChannel, + chan: Arc, _method: String, params: serde_json::Value, ) -> karyon_jsonrpc::Result { @@ -220,7 +222,7 @@ impl MonitorRPC { async fn peer_pool_unsubscribe( &self, - chan: ArcChannel, + chan: Arc, _method: String, params: serde_json::Value, ) -> karyon_jsonrpc::Result { @@ -231,7 +233,7 @@ impl MonitorRPC { async fn discovery_unsubscribe( &self, - chan: ArcChannel, + chan: Arc, _method: String, params: serde_json::Value, ) -> karyon_jsonrpc::Result { @@ -243,6 +245,7 @@ impl MonitorRPC { fn main() { env_logger::init(); + let cli = Cli::parse(); let key_pair = KeyPair::generate(&KeyPairType::Ed25519); diff --git a/p2p/examples/tokio-example/Cargo.lock b/p2p/examples/tokio-example/Cargo.lock index 21a1c63..eaf5b9d 100644 --- a/p2p/examples/tokio-example/Cargo.lock +++ b/p2p/examples/tokio-example/Cargo.lock @@ -885,7 +885,7 @@ dependencies = [ [[package]] name = "karyon_core" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel", "bincode", @@ -903,7 +903,7 @@ dependencies = [ [[package]] name = "karyon_net" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel", "async-trait", @@ -922,7 +922,7 @@ dependencies = [ [[package]] name = "karyon_p2p" -version = "0.1.0" +version = "0.1.1" dependencies = [ "async-channel", "async-trait", -- cgit v1.2.3