From 99aab446c3f569959f83ab72acfc43bb9e67a095 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 2 Jun 2022 08:24:23 +1000 Subject: [PATCH] Remove network::Error The `network::Error` is not used, remove it. --- src/network/mod.rs | 38 -------------------------------------- src/util/mod.rs | 15 +-------------- 2 files changed, 1 insertion(+), 52 deletions(-) diff --git a/src/network/mod.rs b/src/network/mod.rs index 579b6410..48785333 100644 --- a/src/network/mod.rs +++ b/src/network/mod.rs @@ -18,9 +18,6 @@ //! of Bitcoin data and network messages. //! -use crate::io; -use core::fmt; - pub mod constants; #[cfg(feature = "std")] @@ -47,38 +44,3 @@ pub mod message_filter; #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub mod stream_reader; - -/// Network error -#[derive(Debug)] -#[non_exhaustive] -pub enum Error { - /// And I/O error - Io(io::Error), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - Error::Io(ref e) => write_err!(f, "IO error"; e), - } - } -} - -#[cfg(feature = "std")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use self::Error::*; - - match self { - Io(e) => Some(e) - } - } -} - -#[doc(hidden)] -impl From for Error { - fn from(err: io::Error) -> Self { - Error::Io(err) - } -} diff --git a/src/util/mod.rs b/src/util/mod.rs index 98a1b147..404de072 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -40,7 +40,6 @@ use crate::prelude::*; use crate::io; use core::fmt; -use crate::network; use crate::consensus::encode; /// A trait which allows numbers to act as fixed-size bit arrays @@ -71,8 +70,6 @@ pub trait BitArray { pub enum Error { /// Encoding error Encode(encode::Error), - /// Network error - Network(network::Error), /// The header hash is not below the target BlockBadProofOfWork, /// The `target` field of a block header did not match the expected difficulty @@ -83,7 +80,6 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::Encode(ref e) => write_err!(f, "encoding error"; e), - Error::Network(ref e) => write_err!(f, "network error"; e), Error::BlockBadProofOfWork => f.write_str("block target correct but not attained"), Error::BlockBadTarget => f.write_str("block target incorrect"), } @@ -98,9 +94,7 @@ impl std::error::Error for Error { match self { Encode(e) => Some(e), - Network(e) => Some(e), - BlockBadProofOfWork - | BlockBadTarget => None + BlockBadProofOfWork | BlockBadTarget => None } } } @@ -112,13 +106,6 @@ impl From for Error { } } -#[doc(hidden)] -impl From for Error { - fn from(e: network::Error) -> Error { - Error::Network(e) - } -} - // core2 doesn't have read_to_end pub(crate) fn read_to_end(mut d: D) -> Result, io::Error> { let mut result = vec![];