fix sharedpeererror to propagate tracing context
This commit is contained in:
parent
fa6b098056
commit
df18ac72c5
|
|
@ -2344,6 +2344,7 @@ dependencies = [
|
||||||
"tower",
|
"tower",
|
||||||
"tower-load",
|
"tower-load",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"tracing-error",
|
||||||
"tracing-futures",
|
"tracing-futures",
|
||||||
"zebra-chain",
|
"zebra-chain",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -36,3 +36,4 @@ tower-load = "0.3"
|
||||||
metrics = "0.12"
|
metrics = "0.12"
|
||||||
|
|
||||||
zebra-chain = { path = "../zebra-chain" }
|
zebra-chain = { path = "../zebra-chain" }
|
||||||
|
tracing-error = { version = "0.1.2", features = ["traced-error"] }
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,20 @@ use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use tracing_error::TracedError;
|
||||||
use zebra_chain::serialization::SerializationError;
|
use zebra_chain::serialization::SerializationError;
|
||||||
|
|
||||||
/// A wrapper around `Arc<PeerError>` that implements `Error`.
|
/// A wrapper around `Arc<PeerError>` that implements `Error`.
|
||||||
#[derive(Error, Debug, Clone)]
|
#[derive(Error, Debug, Clone)]
|
||||||
#[error("{0}")]
|
#[error(transparent)]
|
||||||
pub struct SharedPeerError(Arc<PeerError>);
|
pub struct SharedPeerError(Arc<TracedError<PeerError>>);
|
||||||
|
|
||||||
impl<E> From<E> for SharedPeerError
|
impl<E> From<E> for SharedPeerError
|
||||||
where
|
where
|
||||||
PeerError: From<E>,
|
PeerError: From<E>,
|
||||||
{
|
{
|
||||||
fn from(source: E) -> Self {
|
fn from(source: E) -> Self {
|
||||||
Self(Arc::new(PeerError::from(source)))
|
Self(Arc::new(TracedError::from(PeerError::from(source))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,14 @@ where
|
||||||
|
|
||||||
async fn drain_requests(&mut self, request_goal: usize) -> Result<(), Report> {
|
async fn drain_requests(&mut self, request_goal: usize) -> Result<(), Report> {
|
||||||
while self.block_requests.len() > request_goal {
|
while self.block_requests.len() > request_goal {
|
||||||
match self.block_requests.next().await {
|
match self
|
||||||
Some(Ok(zebra_network::Response::Blocks(blocks))) => {
|
.block_requests
|
||||||
|
.next()
|
||||||
|
.await
|
||||||
|
.expect("expected: block_requests is never empty")
|
||||||
|
.map_err::<Report, _>(|e| eyre!(e))
|
||||||
|
{
|
||||||
|
Ok(zebra_network::Response::Blocks(blocks)) => {
|
||||||
for block in blocks {
|
for block in blocks {
|
||||||
self.downloaded_block_heights
|
self.downloaded_block_heights
|
||||||
.insert(block.coinbase_height().unwrap());
|
.insert(block.coinbase_height().unwrap());
|
||||||
|
|
@ -225,12 +231,9 @@ where
|
||||||
.map_err(|e| eyre!(e))?;
|
.map_err(|e| eyre!(e))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Ok(_)) => continue,
|
Ok(_) => continue,
|
||||||
Some(Err(e)) => {
|
Err(e) => {
|
||||||
error!(%e);
|
error!("{:?}", e);
|
||||||
}
|
|
||||||
None => {
|
|
||||||
unreachable!("None is never encountered due to the condition on the while loop")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue