cleanup API for arc based error type (#469)
Co-authored-by: Jane Lusby <jane@zfnd.org>
This commit is contained in:
parent
334329f38a
commit
4b9e4520ce
|
@ -79,7 +79,7 @@ impl Handler {
|
|||
GetBlocksByHash { hashes, blocks }
|
||||
}
|
||||
} else {
|
||||
Finished(Err(Arc::new(PeerError::WrongBlock).into()))
|
||||
Finished(Err(PeerError::WrongBlock.into()))
|
||||
}
|
||||
}
|
||||
(FindBlocks, Message::Inv(inv_hashes)) => Finished(Ok(Response::BlockHeaderHashes(
|
||||
|
@ -227,7 +227,7 @@ where
|
|||
}
|
||||
// Other request timeouts fail the request.
|
||||
State::AwaitingResponse(_, tx) => {
|
||||
let _ = tx.send(Err(Arc::new(e).into()));
|
||||
let _ = tx.send(Err(e.into()));
|
||||
State::AwaitingRequest
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
@ -267,7 +267,7 @@ where
|
|||
if guard.is_some() {
|
||||
panic!("called fail_with on already-failed connection state");
|
||||
} else {
|
||||
*guard = Some(Arc::new(e).into());
|
||||
*guard = Some(e.into());
|
||||
}
|
||||
// Drop the guard immediately to release the mutex.
|
||||
std::mem::drop(guard);
|
||||
|
|
|
@ -7,7 +7,16 @@ use zebra_chain::serialization::SerializationError;
|
|||
/// A wrapper around `Arc<PeerError>` that implements `Error`.
|
||||
#[derive(Error, Debug, Clone)]
|
||||
#[error("{0}")]
|
||||
pub struct SharedPeerError(#[from] Arc<PeerError>);
|
||||
pub struct SharedPeerError(Arc<PeerError>);
|
||||
|
||||
impl<E> From<E> for SharedPeerError
|
||||
where
|
||||
PeerError: From<E>,
|
||||
{
|
||||
fn from(source: E) -> Self {
|
||||
Self(Arc::new(PeerError::from(source)))
|
||||
}
|
||||
}
|
||||
|
||||
/// An error related to peer connection handling.
|
||||
#[derive(Error, Debug)]
|
||||
|
|
Loading…
Reference in New Issue