From 6461e2db8d13b3c374f34746476efb714b66d55a Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 6 Jun 2022 13:57:02 +1000 Subject: [PATCH] Run formatter on examples/ Remove "examples" from the rustfmt ignore list. --- examples/bip32.rs | 20 +++++++------------- examples/handshake.rs | 7 ++----- rustfmt.toml | 1 - 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/examples/bip32.rs b/examples/bip32.rs index 6dfd3889..8ebdd845 100644 --- a/examples/bip32.rs +++ b/examples/bip32.rs @@ -1,17 +1,14 @@ extern crate bitcoin; -use std::{env, process}; use std::str::FromStr; +use std::{env, process}; -use bitcoin::secp256k1::Secp256k1; -use bitcoin::PublicKey; -use bitcoin::util::bip32::ExtendedPrivKey; -use bitcoin::util::bip32::ExtendedPubKey; -use bitcoin::util::bip32::DerivationPath; -use bitcoin::util::bip32::ChildNumber; -use bitcoin::util::address::Address; -use bitcoin::secp256k1::ffi::types::AlignedType; use bitcoin::hashes::hex::FromHex; +use bitcoin::secp256k1::ffi::types::AlignedType; +use bitcoin::secp256k1::Secp256k1; +use bitcoin::util::address::Address; +use bitcoin::util::bip32::{ChildNumber, DerivationPath, ExtendedPrivKey, ExtendedPubKey}; +use bitcoin::PublicKey; fn main() { // This example derives root xprv from a 32-byte seed, @@ -55,10 +52,7 @@ fn main() { // generate first receiving address at m/0/0 // manually creating indexes this time let zero = ChildNumber::from_normal_idx(0).unwrap(); - let public_key = xpub.derive_pub(&secp, &vec![zero, zero]) - .unwrap() - .public_key; + let public_key = xpub.derive_pub(&secp, &vec![zero, zero]).unwrap().public_key; let address = Address::p2wpkh(&PublicKey::new(public_key), network).unwrap(); println!("First receiving address: {}", address); - } diff --git a/examples/handshake.rs b/examples/handshake.rs index 9c4cf046..8852b042 100644 --- a/examples/handshake.rs +++ b/examples/handshake.rs @@ -1,9 +1,9 @@ extern crate bitcoin; +use std::io::{BufReader, Write}; use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpStream}; use std::time::{SystemTime, UNIX_EPOCH}; use std::{env, process}; -use std::io::{Write, BufReader}; use bitcoin::consensus::{encode, Decodable}; use bitcoin::network::{address, constants, message, message_network}; @@ -80,10 +80,7 @@ fn build_version_message(address: SocketAddr) -> message::NetworkMessage { let services = constants::ServiceFlags::NONE; // "standard UNIX timestamp in seconds" - let timestamp = SystemTime::now() - .duration_since(UNIX_EPOCH) - .expect("Time error") - .as_secs(); + let timestamp = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time error").as_secs(); // "The network address of the node receiving this message" let addr_recv = address::Address::new(&address, constants::ServiceFlags::NONE); diff --git a/rustfmt.toml b/rustfmt.toml index 01126f28..9e22e91c 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,5 @@ # Eventually this shoud be: ignore = [] ignore = [ - "examples", "src", "src/blockdata", "src/consensus",