use crate::parents::Family;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("unknown parent \"{0}\": one of btc, tbtc4, xbt, txbt4, ltc, vtc (SPEC 3.2)")]
UnknownParent(String),
#[error(
"parent \"{alias}\" ({label}) is reserved: no validator carries its rules yet (SPEC 3.2)"
)]
ReservedParent {
alias: &'static str,
label: &'static str,
},
#[error("the document's parent hands down the {0:?} header family, not the one this validator is instantiated for (SPEC 3.2: stock for btc/tbtc4, BLAKE2b for xbt/txbt4)")]
UnsupportedFamily(Family),
#[error("chain document: {0}")]
Document(String),
#[error("json: {0}")]
Json(#[from] serde_json::Error),
#[error("encoding: {0}")]
Encoding(String),
#[error("{0}")]
CoinbaseHeight(String),
#[error("block {height} failed: {}", rules.join(", "))]
Rejected {
height: u32,
rules: Vec<String>,
},
#[error("{0}")]
Chain(String),
#[error("genesis {found} is not the document's {expected}")]
GenesisMismatch {
found: String,
expected: String,
},
#[error("{0}")]
Transaction(String),
#[error("{0}")]
Block(String),
#[error("federation: {0}")]
Federation(String),
#[error("parent: {0}")]
Parent(String),
#[error("secp256k1: {0}")]
Secp(#[from] bitcoin::secp256k1::Error),
#[cfg(feature = "std")]
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("block file: {0}")]
BlockFile(String),
}
pub type Result<T> = core::result::Result<T, Error>;