Remove trailing whitespace
Remove trailing whitespace from all rust source files. Done with: find . -name *.rs | xargs perl -pli -e "s/\s*$//"
This commit is contained in:
parent
efa9555ebd
commit
1c502399f1
|
@ -112,9 +112,9 @@ impl fmt::Debug for Address {
|
||||||
let ipv6 = Ipv6Addr::from(self.address);
|
let ipv6 = Ipv6Addr::from(self.address);
|
||||||
|
|
||||||
match ipv6.to_ipv4() {
|
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),
|
self.services, addr, self.port),
|
||||||
None => write!(f, "Address {{services: {}, address: {}, port: {}}}",
|
None => write!(f, "Address {{services: {}, address: {}, port: {}}}",
|
||||||
self.services, ipv6, self.port)
|
self.services, ipv6, self.port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ pub enum AddrV2 {
|
||||||
impl Encodable for AddrV2 {
|
impl Encodable for AddrV2 {
|
||||||
fn consensus_encode<W: io::Write>(&self, e: W) -> Result<usize, io::Error> {
|
fn consensus_encode<W: io::Write>(&self, e: W) -> Result<usize, io::Error> {
|
||||||
fn encode_addr<W: io::Write>(mut e: W, network: u8, bytes: &[u8]) -> Result<usize, io::Error> {
|
fn encode_addr<W: io::Write>(mut e: W, network: u8, bytes: &[u8]) -> Result<usize, io::Error> {
|
||||||
let len =
|
let len =
|
||||||
network.consensus_encode(&mut e)? +
|
network.consensus_encode(&mut e)? +
|
||||||
VarInt(bytes.len() as u64).consensus_encode(&mut e)? +
|
VarInt(bytes.len() as u64).consensus_encode(&mut e)? +
|
||||||
bytes.len();
|
bytes.len();
|
||||||
|
@ -182,7 +182,7 @@ impl Decodable for AddrV2 {
|
||||||
}
|
}
|
||||||
let addr: [u8; 4] = Decodable::consensus_decode(&mut d)?;
|
let addr: [u8; 4] = Decodable::consensus_decode(&mut d)?;
|
||||||
AddrV2::Ipv4(Ipv4Addr::new(addr[0], addr[1], addr[2], addr[3]))
|
AddrV2::Ipv4(Ipv4Addr::new(addr[0], addr[1], addr[2], addr[3]))
|
||||||
},
|
},
|
||||||
2 => {
|
2 => {
|
||||||
if len != 16 {
|
if len != 16 {
|
||||||
return Err(encode::Error::ParseFailed("Invalid IPv6 address"));
|
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[0],addr[1],addr[2],addr[3],
|
||||||
addr[4],addr[5],addr[6],addr[7]
|
addr[4],addr[5],addr[6],addr[7]
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
3 => {
|
3 => {
|
||||||
if len != 10 {
|
if len != 10 {
|
||||||
return Err(encode::Error::ParseFailed("Invalid TorV2 address"));
|
return Err(encode::Error::ParseFailed("Invalid TorV2 address"));
|
||||||
|
@ -219,7 +219,7 @@ impl Decodable for AddrV2 {
|
||||||
}
|
}
|
||||||
let hash = Decodable::consensus_decode(&mut d)?;
|
let hash = Decodable::consensus_decode(&mut d)?;
|
||||||
AddrV2::I2p(hash)
|
AddrV2::I2p(hash)
|
||||||
},
|
},
|
||||||
6 => {
|
6 => {
|
||||||
if len != 16 {
|
if len != 16 {
|
||||||
return Err(encode::Error::ParseFailed("Invalid CJDNS address"));
|
return Err(encode::Error::ParseFailed("Invalid CJDNS address"));
|
||||||
|
@ -240,7 +240,7 @@ impl Decodable for AddrV2 {
|
||||||
let mut addr = vec![0u8; len as usize];
|
let mut addr = vec![0u8; len as usize];
|
||||||
d.read_slice(&mut addr)?;
|
d.read_slice(&mut addr)?;
|
||||||
AddrV2::Unknown(network_id, 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
|
//TODO `len += io::Write::write(&mut e, &self.port.to_be_bytes())?;` when MSRV >= 1.32
|
||||||
len += self.port.swap_bytes().consensus_encode(e)?;
|
len += self.port.swap_bytes().consensus_encode(e)?;
|
||||||
Ok(len)
|
Ok(len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Decodable for AddrV2Message {
|
impl Decodable for AddrV2Message {
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl ServiceFlags {
|
||||||
/// WITNESS indicates that a node can be asked for blocks and transactions including witness
|
/// WITNESS indicates that a node can be asked for blocks and transactions including witness
|
||||||
/// data.
|
/// data.
|
||||||
pub const WITNESS: ServiceFlags = ServiceFlags(1 << 3);
|
pub const WITNESS: ServiceFlags = ServiceFlags(1 << 3);
|
||||||
|
|
||||||
/// COMPACT_FILTERS means the node will service basic block filter requests.
|
/// COMPACT_FILTERS means the node will service basic block filter requests.
|
||||||
/// See BIP157 and BIP158 for details on how this is implemented.
|
/// See BIP157 and BIP158 for details on how this is implemented.
|
||||||
pub const COMPACT_FILTERS: ServiceFlags = ServiceFlags(1 << 6);
|
pub const COMPACT_FILTERS: ServiceFlags = ServiceFlags(1 << 6);
|
||||||
|
@ -371,7 +371,7 @@ mod tests {
|
||||||
|
|
||||||
flags2 ^= ServiceFlags::WITNESS;
|
flags2 ^= ServiceFlags::WITNESS;
|
||||||
assert_eq!(flags2, ServiceFlags::GETUTXO);
|
assert_eq!(flags2, ServiceFlags::GETUTXO);
|
||||||
|
|
||||||
flags2 |= ServiceFlags::COMPACT_FILTERS;
|
flags2 |= ServiceFlags::COMPACT_FILTERS;
|
||||||
flags2 ^= ServiceFlags::GETUTXO;
|
flags2 ^= ServiceFlags::GETUTXO;
|
||||||
assert_eq!(flags2, ServiceFlags::COMPACT_FILTERS);
|
assert_eq!(flags2, ServiceFlags::COMPACT_FILTERS);
|
||||||
|
|
|
@ -29,21 +29,21 @@
|
||||||
//! fn get_script_for_coin(coin: &OutPoint) -> Result<Script, BlockFilterError> {
|
//! fn get_script_for_coin(coin: &OutPoint) -> Result<Script, BlockFilterError> {
|
||||||
//! // get utxo ...
|
//! // get utxo ...
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! // create a block filter for a block (server side)
|
//! // create a block filter for a block (server side)
|
||||||
//! let filter = BlockFilter::new_script_filter(&block, get_script_for_coin)?;
|
//! let filter = BlockFilter::new_script_filter(&block, get_script_for_coin)?;
|
||||||
//!
|
//!
|
||||||
//! // or create a filter from known raw data
|
//! // or create a filter from known raw data
|
||||||
//! let filter = BlockFilter::new(content);
|
//! let filter = BlockFilter::new(content);
|
||||||
//!
|
//!
|
||||||
//! // read and evaluate a filter
|
//! // read and evaluate a filter
|
||||||
//!
|
//!
|
||||||
//! let query: Iterator<Item=Script> = // .. some scripts you care about
|
//! let query: Iterator<Item=Script> = // .. some scripts you care about
|
||||||
//! if filter.match_any(&block_hash, &mut query.map(|s| s.as_bytes())) {
|
//! if filter.match_any(&block_hash, &mut query.map(|s| s.as_bytes())) {
|
||||||
//! // get this block
|
//! // get this block
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue