diff options
author | hozan23 <hozan23@karyontech.net> | 2024-06-13 05:52:48 +0200 |
---|---|---|
committer | hozan23 <hozan23@karyontech.net> | 2024-06-13 05:52:48 +0200 |
commit | 1c27f751c30196e2c421ae420dacbc4ff25f0fc7 (patch) | |
tree | e9a34bea9e6fd45d53a4ad1a7a4e75857ad2fe9a /p2p/examples | |
parent | d6a280f69a6685d5b4da5366626fb76a27f0cc07 (diff) |
jsonrpc: spread out comments and clean up
Diffstat (limited to 'p2p/examples')
-rw-r--r-- | p2p/examples/monitor/Cargo.lock | 10 | ||||
-rw-r--r-- | p2p/examples/monitor/src/client.rs | 3 | ||||
-rw-r--r-- | p2p/examples/monitor/src/main.rs | 23 | ||||
-rw-r--r-- | p2p/examples/tokio-example/Cargo.lock | 6 |
4 files changed, 23 insertions, 19 deletions
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<Channel>, method: String, _params: serde_json::Value, ) -> karyon_jsonrpc::Result<serde_json::Value> { 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<Channel>, method: String, _params: serde_json::Value, ) -> karyon_jsonrpc::Result<serde_json::Value> { 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<Channel>, method: String, _params: serde_json::Value, ) -> karyon_jsonrpc::Result<serde_json::Value> { 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<Channel>, _method: String, params: serde_json::Value, ) -> karyon_jsonrpc::Result<serde_json::Value> { @@ -220,7 +222,7 @@ impl MonitorRPC { async fn peer_pool_unsubscribe( &self, - chan: ArcChannel, + chan: Arc<Channel>, _method: String, params: serde_json::Value, ) -> karyon_jsonrpc::Result<serde_json::Value> { @@ -231,7 +233,7 @@ impl MonitorRPC { async fn discovery_unsubscribe( &self, - chan: ArcChannel, + chan: Arc<Channel>, _method: String, params: serde_json::Value, ) -> karyon_jsonrpc::Result<serde_json::Value> { @@ -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", |