chore: add some traces (#1622)

* chore: add some traces

* Update ethers-providers/src/transports/ws.rs

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Matthias Seitz 2022-08-21 00:32:10 +02:00 committed by GitHub
parent 8abb9d86e2
commit da8c70ab7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,7 @@ use std::{
pin::Pin,
task::{Context, Poll},
};
use tracing::error;
/// A transport implementation supporting pub sub subscriptions.
pub trait PubsubClient: JsonRpcClient {
@ -90,7 +91,10 @@ where
match futures_util::ready!(this.rx.poll_next(ctx)) {
Some(item) => match serde_json::from_str(item.get()) {
Ok(res) => Poll::Ready(Some(res)),
_ => Poll::Pending,
Err(err) => {
error!("failed to deserialize item {:?}", err);
Poll::Pending
}
},
None => Poll::Ready(None),
}

View File

@ -22,6 +22,7 @@ use std::{
},
};
use thiserror::Error;
use tracing::trace;
use super::common::{Params, Response};
@ -317,6 +318,7 @@ where
}
async fn handle_text(&mut self, inner: String) -> Result<(), ClientError> {
trace!(msg=?inner, "received message");
let (id, result) = match serde_json::from_str(&inner)? {
Response::Success { id, result } => (id, Ok(result.to_owned())),
Response::Error { id, error } => (id, Err(error)),