Remove redundant code / configurations
This commit is contained in:
parent
2d70623356
commit
eda47c31c9
|
@ -10,9 +10,6 @@ description = "General purpose library for using and interoperating with Bitcoin
|
||||||
keywords = [ "crypto", "bitcoin" ]
|
keywords = [ "crypto", "bitcoin" ]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "bitcoin"
|
|
||||||
path = "src/lib.rs"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
fuzztarget = ["secp256k1/fuzztarget", "bitcoin_hashes/fuzztarget"]
|
fuzztarget = ["secp256k1/fuzztarget", "bitcoin_hashes/fuzztarget"]
|
||||||
|
|
|
@ -142,7 +142,7 @@ impl error::Error for ParseOutPointError {
|
||||||
/// It does not permit leading zeroes or non-digit characters.
|
/// It does not permit leading zeroes or non-digit characters.
|
||||||
fn parse_vout(s: &str) -> Result<u32, ParseOutPointError> {
|
fn parse_vout(s: &str) -> Result<u32, ParseOutPointError> {
|
||||||
if s.len() > 1 {
|
if s.len() > 1 {
|
||||||
let first = s.chars().nth(0).unwrap();
|
let first = s.chars().next().unwrap();
|
||||||
if first == '0' || first == '+' {
|
if first == '0' || first == '+' {
|
||||||
return Err(ParseOutPointError::VoutNotCanonical);
|
return Err(ParseOutPointError::VoutNotCanonical);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
//! to avoid mixing data of the same hash format (like SHA256d) but of different meaning
|
//! to avoid mixing data of the same hash format (like SHA256d) but of different meaning
|
||||||
//! (transaction id, block hash etc).
|
//! (transaction id, block hash etc).
|
||||||
|
|
||||||
use consensus::encode::{Encodable, Decodable, Error};
|
use hashes::{Hash, sha256, sha256d, hash160};
|
||||||
use hashes::{Hash, sha256, sha256d, ripemd160, hash160};
|
|
||||||
use hashes::hex::{FromHex, ToHex};
|
|
||||||
use util::key::PublicKey;
|
|
||||||
|
|
||||||
macro_rules! impl_hashencode {
|
macro_rules! impl_hashencode {
|
||||||
($hashtype:ident) => {
|
($hashtype:ident) => {
|
||||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -23,17 +23,9 @@
|
||||||
//! software.
|
//! software.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
#![crate_name = "bitcoin"]
|
|
||||||
#![crate_type = "dylib"]
|
|
||||||
#![crate_type = "rlib"]
|
|
||||||
|
|
||||||
// Experimental features we need
|
// Experimental features we need
|
||||||
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
|
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
|
||||||
|
|
||||||
// Clippy whitelist
|
|
||||||
#![cfg_attr(feature = "clippy", allow(needless_range_loop))] // suggests making a big mess of array newtypes
|
|
||||||
#![cfg_attr(feature = "clippy", allow(extend_from_slice))] // `extend_from_slice` only available since 1.6
|
|
||||||
|
|
||||||
// Coding conventions
|
// Coding conventions
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![deny(non_upper_case_globals)]
|
#![deny(non_upper_case_globals)]
|
||||||
|
@ -44,23 +36,17 @@
|
||||||
#![deny(unused_imports)]
|
#![deny(unused_imports)]
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
// In general, rust is absolutely horrid at supporting users doing things like,
|
|
||||||
// for example, compiling Rust code for real environments. Disable useless lints
|
|
||||||
// that don't do anything but annoy us and cant actually ever be resolved.
|
|
||||||
#![allow(bare_trait_objects)]
|
|
||||||
#![allow(ellipsis_inclusive_range_patterns)]
|
|
||||||
|
|
||||||
// Re-exported dependencies.
|
// Re-exported dependencies.
|
||||||
#[macro_use] pub extern crate bitcoin_hashes as hashes;
|
#[macro_use] pub extern crate bitcoin_hashes as hashes;
|
||||||
pub extern crate secp256k1;
|
pub extern crate secp256k1;
|
||||||
pub extern crate bech32;
|
pub extern crate bech32;
|
||||||
|
|
||||||
|
#[cfg(feature="bitcoinconsensus")] extern crate bitcoinconsensus;
|
||||||
#[cfg(feature = "serde")] extern crate serde;
|
#[cfg(feature = "serde")] extern crate serde;
|
||||||
#[cfg(all(test, feature = "serde"))] #[macro_use] extern crate serde_derive; // for 1.22.0 compat
|
#[cfg(all(test, feature = "serde"))] #[macro_use] extern crate serde_derive; // for 1.22.0 compat
|
||||||
#[cfg(all(test, feature = "serde"))] extern crate serde_json;
|
#[cfg(all(test, feature = "serde"))] extern crate serde_json;
|
||||||
#[cfg(all(test, feature = "serde"))] extern crate serde_test;
|
#[cfg(all(test, feature = "serde"))] extern crate serde_test;
|
||||||
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
||||||
#[cfg(feature="bitcoinconsensus")] extern crate bitcoinconsensus;
|
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "16")]
|
#[cfg(target_pointer_width = "16")]
|
||||||
compile_error!("rust-bitcoin cannot be used on 16-bit architectures");
|
compile_error!("rust-bitcoin cannot be used on 16-bit architectures");
|
||||||
|
@ -75,8 +61,6 @@ pub mod network;
|
||||||
pub mod blockdata;
|
pub mod blockdata;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
pub mod consensus;
|
pub mod consensus;
|
||||||
// Do not remove: required in order to get hash types implementation macros to work correctly
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
pub mod hash_types;
|
pub mod hash_types;
|
||||||
|
|
||||||
pub use hash_types::*;
|
pub use hash_types::*;
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub fn bitcoin_merkle_root<T, I>(mut iter: I) -> T
|
||||||
return Default::default();
|
return Default::default();
|
||||||
}
|
}
|
||||||
if iter.len() == 1 {
|
if iter.len() == 1 {
|
||||||
return T::from_inner(iter.nth(0).unwrap().into_inner());
|
return T::from_inner(iter.next().unwrap().into_inner());
|
||||||
}
|
}
|
||||||
// Recursion
|
// Recursion
|
||||||
let half_len = iter.len() / 2 + iter.len() % 2;
|
let half_len = iter.len() / 2 + iter.len() % 2;
|
||||||
|
|
|
@ -445,7 +445,7 @@ impl MerkleBlock {
|
||||||
match_txids: &HashSet<Txid>,
|
match_txids: &HashSet<Txid>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let matches: Vec<bool> = block_txids
|
let matches: Vec<bool> = block_txids
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|txid| match_txids.contains(txid))
|
.map(|txid| match_txids.contains(txid))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue