Remove redundant code / configurations

This commit is contained in:
Elichai Turkel 2020-09-14 17:57:42 +03:00
parent 2d70623356
commit eda47c31c9
No known key found for this signature in database
GPG Key ID: 9383CDE9E8E66A7F
6 changed files with 5 additions and 27 deletions

View File

@ -10,9 +10,6 @@ description = "General purpose library for using and interoperating with Bitcoin
keywords = [ "crypto", "bitcoin" ]
readme = "README.md"
[lib]
name = "bitcoin"
path = "src/lib.rs"
[features]
fuzztarget = ["secp256k1/fuzztarget", "bitcoin_hashes/fuzztarget"]

View File

@ -142,7 +142,7 @@ impl error::Error for ParseOutPointError {
/// It does not permit leading zeroes or non-digit characters.
fn parse_vout(s: &str) -> Result<u32, ParseOutPointError> {
if s.len() > 1 {
let first = s.chars().nth(0).unwrap();
let first = s.chars().next().unwrap();
if first == '0' || first == '+' {
return Err(ParseOutPointError::VoutNotCanonical);
}

View File

@ -16,10 +16,7 @@
//! to avoid mixing data of the same hash format (like SHA256d) but of different meaning
//! (transaction id, block hash etc).
use consensus::encode::{Encodable, Decodable, Error};
use hashes::{Hash, sha256, sha256d, ripemd160, hash160};
use hashes::hex::{FromHex, ToHex};
use util::key::PublicKey;
use hashes::{Hash, sha256, sha256d, hash160};
macro_rules! impl_hashencode {
($hashtype:ident) => {

View File

@ -23,17 +23,9 @@
//! software.
//!
#![crate_name = "bitcoin"]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
// Experimental features we need
#![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
#![forbid(unsafe_code)]
#![deny(non_upper_case_globals)]
@ -44,23 +36,17 @@
#![deny(unused_imports)]
#![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.
#[macro_use] pub extern crate bitcoin_hashes as hashes;
pub extern crate secp256k1;
pub extern crate bech32;
#[cfg(feature="bitcoinconsensus")] extern crate bitcoinconsensus;
#[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"))] extern crate serde_json;
#[cfg(all(test, feature = "serde"))] extern crate serde_test;
#[cfg(all(test, feature = "unstable"))] extern crate test;
#[cfg(feature="bitcoinconsensus")] extern crate bitcoinconsensus;
#[cfg(target_pointer_width = "16")]
compile_error!("rust-bitcoin cannot be used on 16-bit architectures");
@ -75,8 +61,6 @@ pub mod network;
pub mod blockdata;
pub mod util;
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 use hash_types::*;

View File

@ -60,7 +60,7 @@ pub fn bitcoin_merkle_root<T, I>(mut iter: I) -> T
return Default::default();
}
if iter.len() == 1 {
return T::from_inner(iter.nth(0).unwrap().into_inner());
return T::from_inner(iter.next().unwrap().into_inner());
}
// Recursion
let half_len = iter.len() / 2 + iter.len() % 2;

View File

@ -445,7 +445,7 @@ impl MerkleBlock {
match_txids: &HashSet<Txid>,
) -> Self {
let matches: Vec<bool> = block_txids
.into_iter()
.iter()
.map(|txid| match_txids.contains(txid))
.collect();