Skip to content

Commit

Permalink
Remove redundant code / configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
elichai committed Oct 8, 2020
1 parent fa33b1c commit e46433c
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 27 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion src/blockdata/transaction.rs
Expand Up @@ -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);
}
Expand Down
5 changes: 1 addition & 4 deletions src/hash_types.rs
Expand Up @@ -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) => {
Expand Down
18 changes: 1 addition & 17 deletions src/lib.rs
Expand Up @@ -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)]
Expand All @@ -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");
Expand All @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion src/util/hash.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/util/merkleblock.rs
Expand Up @@ -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();

Expand Down

0 comments on commit e46433c

Please sign in to comment.