aboutsummaryrefslogtreecommitdiff
path: root/p2p/examples/monitor/src
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-13 05:52:48 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-13 05:52:48 +0200
commit1c27f751c30196e2c421ae420dacbc4ff25f0fc7 (patch)
treee9a34bea9e6fd45d53a4ad1a7a4e75857ad2fe9a /p2p/examples/monitor/src
parentd6a280f69a6685d5b4da5366626fb76a27f0cc07 (diff)
jsonrpc: spread out comments and clean up
Diffstat (limited to 'p2p/examples/monitor/src')
-rw-r--r--p2p/examples/monitor/src/client.rs3
-rw-r--r--p2p/examples/monitor/src/main.rs23
2 files changed, 15 insertions, 11 deletions
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);