Skip to content

Commit

Permalink
Merge rust-bitcoin/rust-bitcoin#1032: Remove network::Error
Browse files Browse the repository at this point in the history
99aab44 Remove network::Error (Tobin C. Harding)

Pull request description:

  The `network::Error` is not used, remove it.

  (This description has been changed, the thumbs up emojis were put on the previous PR description.)

ACKs for top commit:
  sanket1729:
    reACK 99aab44
  apoelstra:
    ACK 99aab44

Tree-SHA512: 2342531160966860b7b65f8c5df10e169876ec446e6fd30093d5d81d0b0304cad04e2c2057eb3ca6b23a2fc56453c91ad4ddf426d3796fb301acb7f7d03a66b9
  • Loading branch information
apoelstra committed Jun 2, 2022
2 parents 9afed12 + a2df04d commit a580a11
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
38 changes: 0 additions & 38 deletions src/network/mod.rs
Expand Up @@ -18,9 +18,6 @@
//! of Bitcoin data and network messages.
//!

use crate::io;
use core::fmt;

pub mod constants;

#[cfg(feature = "std")]
Expand All @@ -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<io::Error> for Error {
fn from(err: io::Error) -> Self {
Error::Io(err)
}
}
15 changes: 1 addition & 14 deletions src/util/mod.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"),
}
Expand All @@ -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
}
}
}
Expand All @@ -112,13 +106,6 @@ impl From<encode::Error> for Error {
}
}

#[doc(hidden)]
impl From<network::Error> for Error {
fn from(e: network::Error) -> Error {
Error::Network(e)
}
}

// core2 doesn't have read_to_end
pub(crate) fn read_to_end<D: io::Read>(mut d: D) -> Result<Vec<u8>, io::Error> {
let mut result = vec![];
Expand Down

0 comments on commit a580a11

Please sign in to comment.