pub mod address;
pub mod base58;
pub mod contracthash;
pub mod decimal;
pub mod hash;
pub mod iter;
pub mod misc;
pub mod patricia_tree;
pub mod uint;
use byteorder;
use std::io;
pub trait BitArray {
fn bit(&self, idx: usize) -> bool;
fn bit_slice(&self, start: usize, end: usize) -> Self;
fn mask(&self, n: usize) -> Self;
fn trailing_zeros(&self) -> usize;
}
#[derive(Debug)]
pub enum Error {
Io(io::Error),
ByteOrder(byteorder::Error),
BadNetworkMagic(u32, u32),
BadNetworkMessage(String),
DuplicateHash,
BlockNotFound,
ParseFailed,
PrevHashNotFound,
SpvBadTarget,
SpvBadProofOfWork,
Detail(String, Box<Error>)
}
display_from_debug!(Error);
pub fn propagate_err<T>(s: String, res: Result<T, Error>) -> Result<T, Error> {
res.map_err(|err| Error::Detail(s, Box::new(err)))
}