Merge rust-bitcoin/rust-bitcoin#1032: Remove network::Error
99aab446c3
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: reACK99aab446c3
apoelstra: ACK99aab446c3
Tree-SHA512: 2342531160966860b7b65f8c5df10e169876ec446e6fd30093d5d81d0b0304cad04e2c2057eb3ca6b23a2fc56453c91ad4ddf426d3796fb301acb7f7d03a66b9
This commit is contained in:
commit
21f4493813
|
@ -18,9 +18,6 @@
|
||||||
//! of Bitcoin data and network messages.
|
//! of Bitcoin data and network messages.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use crate::io;
|
|
||||||
use core::fmt;
|
|
||||||
|
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
@ -47,38 +44,3 @@ pub mod message_filter;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||||
pub mod stream_reader;
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ use crate::prelude::*;
|
||||||
use crate::io;
|
use crate::io;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
use crate::network;
|
|
||||||
use crate::consensus::encode;
|
use crate::consensus::encode;
|
||||||
|
|
||||||
/// A trait which allows numbers to act as fixed-size bit arrays
|
/// A trait which allows numbers to act as fixed-size bit arrays
|
||||||
|
@ -71,8 +70,6 @@ pub trait BitArray {
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Encoding error
|
/// Encoding error
|
||||||
Encode(encode::Error),
|
Encode(encode::Error),
|
||||||
/// Network error
|
|
||||||
Network(network::Error),
|
|
||||||
/// The header hash is not below the target
|
/// The header hash is not below the target
|
||||||
BlockBadProofOfWork,
|
BlockBadProofOfWork,
|
||||||
/// The `target` field of a block header did not match the expected difficulty
|
/// 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 {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Encode(ref e) => write_err!(f, "encoding error"; e),
|
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::BlockBadProofOfWork => f.write_str("block target correct but not attained"),
|
||||||
Error::BlockBadTarget => f.write_str("block target incorrect"),
|
Error::BlockBadTarget => f.write_str("block target incorrect"),
|
||||||
}
|
}
|
||||||
|
@ -98,9 +94,7 @@ impl std::error::Error for Error {
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Encode(e) => Some(e),
|
Encode(e) => Some(e),
|
||||||
Network(e) => Some(e),
|
BlockBadProofOfWork | BlockBadTarget => None
|
||||||
BlockBadProofOfWork
|
|
||||||
| BlockBadTarget => None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
// core2 doesn't have read_to_end
|
||||||
pub(crate) fn read_to_end<D: io::Read>(mut d: D) -> Result<Vec<u8>, io::Error> {
|
pub(crate) fn read_to_end<D: io::Read>(mut d: D) -> Result<Vec<u8>, io::Error> {
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
|
|
Loading…
Reference in New Issue