Update jsonrpsee reference (#1049)

* update jsonrpsee

* test

* Revert "test"

This reverts commit 2b69652ab92ff0d9649088c76faed2c94384540d.
This commit is contained in:
Svyatoslav Nikolsky
2021-07-19 14:03:59 +03:00
committed by Bastian Köcher
parent 4e18bff37c
commit 6103fbe40b
6 changed files with 34 additions and 24 deletions
@@ -108,12 +108,18 @@ async fn prepare_initialization_data<SourceChain: Chain>(
.map_err(|err| format!("Failed to subscribe to {} justifications: {:?}", SourceChain::NAME, err))?; .map_err(|err| format!("Failed to subscribe to {} justifications: {:?}", SourceChain::NAME, err))?;
// Read next justification - the header that it finalizes will be used as initial header. // Read next justification - the header that it finalizes will be used as initial header.
let justification = justifications.next().await.ok_or_else(|| { let justification = justifications
format!( .next()
"Failed to read {} justification from the stream: stream has ended unexpectedly", .await
SourceChain::NAME, .map_err(|err| err.to_string())
) .and_then(|justification| justification.ok_or_else(|| "stream has ended unexpectedly".into()))
})?; .map_err(|err| {
format!(
"Failed to read {} justification from the stream: {}",
SourceChain::NAME,
err,
)
})?;
// Read initial header. // Read initial header.
let justification: GrandpaJustification<SourceChain::Header> = Decode::decode(&mut &justification.0[..]) let justification: GrandpaJustification<SourceChain::Header> = Decode::decode(&mut &justification.0[..])
+2 -2
View File
@@ -11,8 +11,8 @@ bp-eth-poa = { path = "../../primitives/ethereum-poa" }
codec = { package = "parity-scale-codec", version = "2.2.0" } codec = { package = "parity-scale-codec", version = "2.2.0" }
headers-relay = { path = "../headers" } headers-relay = { path = "../headers" }
hex-literal = "0.3" hex-literal = "0.3"
jsonrpsee-proc-macros = "=0.2.0-alpha.6" jsonrpsee-proc-macros = "0.2"
jsonrpsee-ws-client = "=0.2.0-alpha.6" jsonrpsee-ws-client = "0.2"
libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] } libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] }
log = "0.4.11" log = "0.4.11"
relay-utils = { path = "../utils" } relay-utils = { path = "../utils" }
+2 -3
View File
@@ -57,10 +57,9 @@ impl MaybeConnectionError for Error {
fn is_connection_error(&self) -> bool { fn is_connection_error(&self) -> bool {
matches!( matches!(
*self, *self,
Error::RpcError(RpcError::TransportError(_)) Error::RpcError(RpcError::Transport(_))
// right now if connection to the ws server is dropped (after it is already established),
// we're getting this error
| Error::RpcError(RpcError::Internal(_)) | Error::RpcError(RpcError::Internal(_))
| Error::RpcError(RpcError::RestartNeeded(_))
| Error::ClientNotSynced(_), | Error::ClientNotSynced(_),
) )
} }
+2 -2
View File
@@ -9,8 +9,8 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
async-std = { version = "1.6.5", features = ["attributes"] } async-std = { version = "1.6.5", features = ["attributes"] }
async-trait = "0.1.40" async-trait = "0.1.40"
codec = { package = "parity-scale-codec", version = "2.2.0" } codec = { package = "parity-scale-codec", version = "2.2.0" }
jsonrpsee-proc-macros = "=0.2.0-alpha.6" jsonrpsee-proc-macros = "0.2"
jsonrpsee-ws-client = "=0.2.0-alpha.6" jsonrpsee-ws-client = "0.2"
log = "0.4.11" log = "0.4.11"
num-traits = "0.2" num-traits = "0.2"
rand = "0.7" rand = "0.7"
+1 -3
View File
@@ -71,9 +71,7 @@ impl MaybeConnectionError for Error {
fn is_connection_error(&self) -> bool { fn is_connection_error(&self) -> bool {
matches!( matches!(
*self, *self,
Error::RpcError(RpcError::TransportError(_)) Error::RpcError(RpcError::Transport(_))
// right now if connection to the ws server is dropped (after it is already established),
// we're getting this error
| Error::RpcError(RpcError::Internal(_)) | Error::RpcError(RpcError::Internal(_))
| Error::RpcError(RpcError::RestartNeeded(_)) | Error::RpcError(RpcError::RestartNeeded(_))
| Error::ClientNotSynced(_), | Error::ClientNotSynced(_),
@@ -134,20 +134,27 @@ where
self.client.clone().subscribe_justifications().await?, self.client.clone().subscribe_justifications().await?,
move |mut subscription| async move { move |mut subscription| async move {
loop { loop {
let next_justification = subscription.next().await?; let log_error = |err| {
log::error!(
target: "bridge",
"Failed to read justification target from the {} justifications stream: {:?}",
P::SOURCE_NAME,
err,
);
};
let next_justification = subscription
.next()
.await
.map_err(|err| log_error(err.to_string()))
.ok()??;
let decoded_justification = let decoded_justification =
GrandpaJustification::<C::Header>::decode(&mut &next_justification.0[..]); GrandpaJustification::<C::Header>::decode(&mut &next_justification.0[..]);
let justification = match decoded_justification { let justification = match decoded_justification {
Ok(j) => j, Ok(j) => j,
Err(err) => { Err(err) => {
log::error!( log_error(format!("decode failed with error {:?}", err));
target: "bridge",
"Failed to decode justification target from the {} justifications stream: {:?}",
P::SOURCE_NAME,
err,
);
continue; continue;
} }
}; };