Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Update jsonrpc (#265)
Browse files Browse the repository at this point in the history
* Update jsonrpc

* Update Substrate
  • Loading branch information
bkchr authored Aug 13, 2021
1 parent ef89227 commit a0cc00e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
10 changes: 5 additions & 5 deletions client/beefy/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ edition = "2018"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
futures = { version = "0.3.16", features = ["compat"] }
futures = "0.3.16"
log = "0.4"
serde = { version = "1.0.127", features = ["derive"] }
serde_json = "1.0.64"

jsonrpc-core = "15.1.0"
jsonrpc-core-client = "15.1.0"
jsonrpc-derive = "15.1.0"
jsonrpc-pubsub = "15.1.0"
jsonrpc-core = "18.0.0"
jsonrpc-core-client = "18.0.0"
jsonrpc-derive = "18.0.0"
jsonrpc-pubsub = "18.0.0"

codec = { version = "2.0.0", package = "parity-scale-codec", features = ["derive"] }

Expand Down
18 changes: 5 additions & 13 deletions client/beefy/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
#![warn(missing_docs)]

use beefy_gadget::notification::BeefySignedCommitmentStream;
use futures::{StreamExt, TryStreamExt};
use jsonrpc_core::futures::{
future::{Executor as Executor01, Future as Future01},
sink::Sink as Sink01,
stream::Stream as Stream01,
};
use futures::{FutureExt, SinkExt, StreamExt};
use jsonrpc_derive::rpc;
use jsonrpc_pubsub::{manager::SubscriptionManager, typed::Subscriber, SubscriptionId};
use log::warn;
Expand Down Expand Up @@ -71,7 +66,7 @@ impl<Block: BlockT> BeefyRpcHandler<Block> {
/// Creates a new BeefyRpcHandler instance.
pub fn new<E>(signed_commitment_stream: BeefySignedCommitmentStream<Block>, executor: E) -> Self
where
E: Executor01<Box<dyn Future01<Item = (), Error = ()> + Send>> + Send + Sync + 'static,
E: futures::task::Spawn + Send + Sync + 'static,
{
let manager = SubscriptionManager::new(Arc::new(executor));
Self {
Expand All @@ -95,14 +90,11 @@ where
let stream = self
.signed_commitment_stream
.subscribe()
.map(|x| Ok::<_, ()>(notification::SignedCommitment::new::<Block>(x)))
.map_err(|e| warn!("Notification stream error: {:?}", e))
.compat();
.map(|x| Ok::<_, ()>(Ok(notification::SignedCommitment::new::<Block>(x))));

self.manager.add(subscriber, |sink| {
let stream = stream.map(Ok);
sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e))
.send_all(stream)
stream
.forward(sink.sink_map_err(|e| warn!("Error sending notifications: {:?}", e)))
.map(|_| ())
});
}
Expand Down

0 comments on commit a0cc00e

Please sign in to comment.