Remove unused consensus encoding error variants

The error variants `UnexpectedNetworkMagic` and `UnknownNetworkMagic`
were not only duplicated but also completely unused. This removes both
of them.
This commit is contained in:
Martin Habovstiak 2022-09-08 16:58:46 +02:00
parent ed9012c25c
commit 57c4283220
1 changed files with 1 additions and 15 deletions

View File

@ -43,13 +43,6 @@ pub enum Error {
Io(io::Error), Io(io::Error),
/// PSBT-related error /// PSBT-related error
Psbt(psbt::Error), Psbt(psbt::Error),
/// Network magic was not expected
UnexpectedNetworkMagic {
/// The expected network magic
expected: u32,
/// The unexpected network magic
actual: u32,
},
/// Tried to allocate an oversized vector /// Tried to allocate an oversized vector
OversizedVectorAllocation { OversizedVectorAllocation {
/// The capacity requested /// The capacity requested
@ -66,8 +59,6 @@ pub enum Error {
}, },
/// VarInt was encoded in a non-minimal way /// VarInt was encoded in a non-minimal way
NonMinimalVarInt, NonMinimalVarInt,
/// Network magic was unknown
UnknownNetworkMagic(u32),
/// Parsing error /// Parsing error
ParseFailed(&'static str), ParseFailed(&'static str),
/// Unsupported Segwit flag /// Unsupported Segwit flag
@ -79,14 +70,11 @@ impl fmt::Display for Error {
match *self { match *self {
Error::Io(ref e) => write_err!(f, "IO error"; e), Error::Io(ref e) => write_err!(f, "IO error"; e),
Error::Psbt(ref e) => write_err!(f, "PSBT error"; e), Error::Psbt(ref e) => write_err!(f, "PSBT error"; e),
Error::UnexpectedNetworkMagic { expected: ref e, actual: ref a } => write!(f,
"unexpected network magic: expected {}, actual {}", e, a),
Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f, Error::OversizedVectorAllocation { requested: ref r, max: ref m } => write!(f,
"allocation of oversized vector: requested {}, maximum {}", r, m), "allocation of oversized vector: requested {}, maximum {}", r, m),
Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f, Error::InvalidChecksum { expected: ref e, actual: ref a } => write!(f,
"invalid checksum: expected {}, actual {}", e.to_hex(), a.to_hex()), "invalid checksum: expected {}, actual {}", e.to_hex(), a.to_hex()),
Error::NonMinimalVarInt => write!(f, "non-minimal varint"), Error::NonMinimalVarInt => write!(f, "non-minimal varint"),
Error::UnknownNetworkMagic(ref m) => write!(f, "unknown network magic: {}", m),
Error::ParseFailed(ref s) => write!(f, "parse failed: {}", s), Error::ParseFailed(ref s) => write!(f, "parse failed: {}", s),
Error::UnsupportedSegwitFlag(ref swflag) => write!(f, Error::UnsupportedSegwitFlag(ref swflag) => write!(f,
"unsupported segwit version: {}", swflag), "unsupported segwit version: {}", swflag),
@ -103,11 +91,9 @@ impl std::error::Error for Error {
match self { match self {
Io(e) => Some(e), Io(e) => Some(e),
Psbt(e) => Some(e), Psbt(e) => Some(e),
UnexpectedNetworkMagic { .. } OversizedVectorAllocation { .. }
| OversizedVectorAllocation { .. }
| InvalidChecksum { .. } | InvalidChecksum { .. }
| NonMinimalVarInt | NonMinimalVarInt
| UnknownNetworkMagic(_)
| ParseFailed(_) | ParseFailed(_)
| UnsupportedSegwitFlag(_) => None, | UnsupportedSegwitFlag(_) => None,
} }