From 1c502399f1e46920f75ef653a7bf4c0180bbf24d Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Mon, 24 Jan 2022 11:24:32 +1100 Subject: [PATCH] Remove trailing whitespace Remove trailing whitespace from all rust source files. Done with: find . -name *.rs | xargs perl -pli -e "s/\s*$//" --- src/network/address.rs | 16 ++++++++-------- src/network/constants.rs | 4 ++-- src/util/bip158.rs | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/network/address.rs b/src/network/address.rs index 9cba27e5..6ac7afe4 100644 --- a/src/network/address.rs +++ b/src/network/address.rs @@ -112,9 +112,9 @@ impl fmt::Debug for Address { let ipv6 = Ipv6Addr::from(self.address); match ipv6.to_ipv4() { - Some(addr) => write!(f, "Address {{services: {}, address: {}, port: {}}}", + Some(addr) => write!(f, "Address {{services: {}, address: {}, port: {}}}", self.services, addr, self.port), - None => write!(f, "Address {{services: {}, address: {}, port: {}}}", + None => write!(f, "Address {{services: {}, address: {}, port: {}}}", self.services, ipv6, self.port) } } @@ -149,7 +149,7 @@ pub enum AddrV2 { impl Encodable for AddrV2 { fn consensus_encode(&self, e: W) -> Result { fn encode_addr(mut e: W, network: u8, bytes: &[u8]) -> Result { - let len = + let len = network.consensus_encode(&mut e)? + VarInt(bytes.len() as u64).consensus_encode(&mut e)? + bytes.len(); @@ -182,7 +182,7 @@ impl Decodable for AddrV2 { } let addr: [u8; 4] = Decodable::consensus_decode(&mut d)?; AddrV2::Ipv4(Ipv4Addr::new(addr[0], addr[1], addr[2], addr[3])) - }, + }, 2 => { if len != 16 { return Err(encode::Error::ParseFailed("Invalid IPv6 address")); @@ -198,7 +198,7 @@ impl Decodable for AddrV2 { addr[0],addr[1],addr[2],addr[3], addr[4],addr[5],addr[6],addr[7] )) - }, + }, 3 => { if len != 10 { return Err(encode::Error::ParseFailed("Invalid TorV2 address")); @@ -219,7 +219,7 @@ impl Decodable for AddrV2 { } let hash = Decodable::consensus_decode(&mut d)?; AddrV2::I2p(hash) - }, + }, 6 => { if len != 16 { return Err(encode::Error::ParseFailed("Invalid CJDNS address")); @@ -240,7 +240,7 @@ impl Decodable for AddrV2 { let mut addr = vec![0u8; len as usize]; d.read_slice(&mut addr)?; AddrV2::Unknown(network_id, addr) - } + } }) } } @@ -282,7 +282,7 @@ impl Encodable for AddrV2Message { //TODO `len += io::Write::write(&mut e, &self.port.to_be_bytes())?;` when MSRV >= 1.32 len += self.port.swap_bytes().consensus_encode(e)?; Ok(len) - } + } } impl Decodable for AddrV2Message { diff --git a/src/network/constants.rs b/src/network/constants.rs index ed4f67d8..7c9390b7 100644 --- a/src/network/constants.rs +++ b/src/network/constants.rs @@ -144,7 +144,7 @@ impl ServiceFlags { /// WITNESS indicates that a node can be asked for blocks and transactions including witness /// data. pub const WITNESS: ServiceFlags = ServiceFlags(1 << 3); - + /// COMPACT_FILTERS means the node will service basic block filter requests. /// See BIP157 and BIP158 for details on how this is implemented. pub const COMPACT_FILTERS: ServiceFlags = ServiceFlags(1 << 6); @@ -371,7 +371,7 @@ mod tests { flags2 ^= ServiceFlags::WITNESS; assert_eq!(flags2, ServiceFlags::GETUTXO); - + flags2 |= ServiceFlags::COMPACT_FILTERS; flags2 ^= ServiceFlags::GETUTXO; assert_eq!(flags2, ServiceFlags::COMPACT_FILTERS); diff --git a/src/util/bip158.rs b/src/util/bip158.rs index a97cd972..7273db20 100644 --- a/src/util/bip158.rs +++ b/src/util/bip158.rs @@ -29,21 +29,21 @@ //! fn get_script_for_coin(coin: &OutPoint) -> Result { //! // get utxo ... //! } -//! +//! //! // create a block filter for a block (server side) //! let filter = BlockFilter::new_script_filter(&block, get_script_for_coin)?; //! //! // or create a filter from known raw data //! let filter = BlockFilter::new(content); -//! +//! //! // read and evaluate a filter -//! +//! //! let query: Iterator = // .. some scripts you care about //! if filter.match_any(&block_hash, &mut query.map(|s| s.as_bytes())) { //! // get this block //! } //! ``` -//! +//! use prelude::*;