aboutsummaryrefslogtreecommitdiff
path: root/p2p/examples/monitor
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/examples/monitor')
-rw-r--r--p2p/examples/monitor/Cargo.lock10
-rw-r--r--p2p/examples/monitor/src/client.rs3
-rw-r--r--p2p/examples/monitor/src/main.rs23
3 files changed, 20 insertions, 16 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);