mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
rpc: Update jsonrpsee v0.15.1 (#11939)
* Bump jsonrpsee to v0.15.1 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc-servers: Adjust RpcMiddleware to WS and HTTP traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/author: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/chain: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/state: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/finality-grandpa: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/beefy: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client: Extract RPC string result from queries Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply rust-fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix warnings Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/tests: Remove trailing comma Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Use `SubscriptionResult` for implementations Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Remove comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Delegate middleware calls to `RpcMiddleware` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Remove comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert Cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update Cargo.lock with minimal changes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Update imports for `SubscriptionResult` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply cargo fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/tests: Submit raw json requests to validate DenyUnsafe Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -26,7 +26,7 @@ use futures::{
|
||||
future::{self, FutureExt},
|
||||
stream::{self, Stream, StreamExt},
|
||||
};
|
||||
use jsonrpsee::PendingSubscription;
|
||||
use jsonrpsee::SubscriptionSink;
|
||||
use sc_client_api::{BlockBackend, BlockchainEvents};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_runtime::{
|
||||
@@ -69,7 +69,7 @@ where
|
||||
self.client.block(&BlockId::Hash(self.unwrap_or_best(hash))).map_err(client_err)
|
||||
}
|
||||
|
||||
fn subscribe_all_heads(&self, sink: PendingSubscription) {
|
||||
fn subscribe_all_heads(&self, sink: SubscriptionSink) {
|
||||
subscribe_headers(
|
||||
&self.client,
|
||||
&self.executor,
|
||||
@@ -83,7 +83,7 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
fn subscribe_new_heads(&self, sink: PendingSubscription) {
|
||||
fn subscribe_new_heads(&self, sink: SubscriptionSink) {
|
||||
subscribe_headers(
|
||||
&self.client,
|
||||
&self.executor,
|
||||
@@ -98,7 +98,7 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
fn subscribe_finalized_heads(&self, sink: PendingSubscription) {
|
||||
fn subscribe_finalized_heads(&self, sink: SubscriptionSink) {
|
||||
subscribe_headers(
|
||||
&self.client,
|
||||
&self.executor,
|
||||
@@ -117,7 +117,7 @@ where
|
||||
fn subscribe_headers<Block, Client, F, G, S>(
|
||||
client: &Arc<Client>,
|
||||
executor: &SubscriptionTaskExecutor,
|
||||
pending: PendingSubscription,
|
||||
mut sink: SubscriptionSink,
|
||||
best_block_hash: G,
|
||||
stream: F,
|
||||
) where
|
||||
@@ -143,9 +143,7 @@ fn subscribe_headers<Block, Client, F, G, S>(
|
||||
let stream = stream::iter(maybe_header).chain(stream());
|
||||
|
||||
let fut = async move {
|
||||
if let Some(mut sink) = pending.accept() {
|
||||
sink.pipe_from_stream(stream).await;
|
||||
}
|
||||
sink.pipe_from_stream(stream).await;
|
||||
};
|
||||
|
||||
executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed());
|
||||
|
||||
@@ -27,7 +27,7 @@ use std::sync::Arc;
|
||||
|
||||
use crate::SubscriptionTaskExecutor;
|
||||
|
||||
use jsonrpsee::{core::RpcResult, PendingSubscription};
|
||||
use jsonrpsee::{core::RpcResult, types::SubscriptionResult, SubscriptionSink};
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use sp_rpc::{list::ListOrValue, number::NumberOrHex};
|
||||
use sp_runtime::{
|
||||
@@ -95,13 +95,13 @@ where
|
||||
}
|
||||
|
||||
/// All new head subscription
|
||||
fn subscribe_all_heads(&self, sink: PendingSubscription);
|
||||
fn subscribe_all_heads(&self, sink: SubscriptionSink);
|
||||
|
||||
/// New best head subscription
|
||||
fn subscribe_new_heads(&self, sink: PendingSubscription);
|
||||
fn subscribe_new_heads(&self, sink: SubscriptionSink);
|
||||
|
||||
/// Finalized head subscription
|
||||
fn subscribe_finalized_heads(&self, sink: PendingSubscription);
|
||||
fn subscribe_finalized_heads(&self, sink: SubscriptionSink);
|
||||
}
|
||||
|
||||
/// Create new state API that works on full node.
|
||||
@@ -160,16 +160,19 @@ where
|
||||
self.backend.finalized_head().map_err(Into::into)
|
||||
}
|
||||
|
||||
fn subscribe_all_heads(&self, sink: PendingSubscription) {
|
||||
self.backend.subscribe_all_heads(sink)
|
||||
fn subscribe_all_heads(&self, sink: SubscriptionSink) -> SubscriptionResult {
|
||||
self.backend.subscribe_all_heads(sink);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn subscribe_new_heads(&self, sink: PendingSubscription) {
|
||||
self.backend.subscribe_new_heads(sink)
|
||||
fn subscribe_new_heads(&self, sink: SubscriptionSink) -> SubscriptionResult {
|
||||
self.backend.subscribe_new_heads(sink);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn subscribe_finalized_heads(&self, sink: PendingSubscription) {
|
||||
self.backend.subscribe_finalized_heads(sink)
|
||||
fn subscribe_finalized_heads(&self, sink: SubscriptionSink) -> SubscriptionResult {
|
||||
self.backend.subscribe_finalized_heads(sink);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user