Refactor whitespace
Do various whitespace refactorings, of note: - Use space around equals e.g., 'since = "blah"' - Put return/break/continue on separate line Whitespace only, no logic changes.
This commit is contained in:
parent
1c502399f1
commit
bf4f5638e0
|
@ -674,7 +674,7 @@ impl fmt::Display for NonStandardSigHashType {
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||||
impl error::Error for NonStandardSigHashType {}
|
impl error::Error for NonStandardSigHashType {}
|
||||||
|
|
||||||
/// Legacy Hashtype of an input's signature.
|
/// Legacy Hashtype of an input's signature
|
||||||
#[deprecated(since = "0.28.0", note = "Please use [`EcdsaSigHashType`] instead")]
|
#[deprecated(since = "0.28.0", note = "Please use [`EcdsaSigHashType`] instead")]
|
||||||
pub type SigHashType = EcdsaSigHashType;
|
pub type SigHashType = EcdsaSigHashType;
|
||||||
|
|
||||||
|
|
|
@ -439,7 +439,6 @@ impl Decodable for VarInt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Booleans
|
// Booleans
|
||||||
impl Encodable for bool {
|
impl Encodable for bool {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -385,4 +385,3 @@ mod tests {
|
||||||
assert_eq!("ServiceFlags(WITNESS|COMPACT_FILTERS|0xb0)", flag.to_string());
|
assert_eq!("ServiceFlags(WITNESS|COMPACT_FILTERS|0xb0)", flag.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,4 +27,3 @@ macro_rules! serde_round_trip (
|
||||||
assert_eq!($var, decoded);
|
assert_eq!($var, decoded);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ use hashes::{Hash, hash160, hex, hex::FromHex};
|
||||||
use hash_types::{PubkeyHash, WPubkeyHash};
|
use hash_types::{PubkeyHash, WPubkeyHash};
|
||||||
use util::base58;
|
use util::base58;
|
||||||
|
|
||||||
|
|
||||||
/// A key-related error.
|
/// A key-related error.
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
@ -45,7 +44,6 @@ pub enum Error {
|
||||||
Hex(hex::Error)
|
Hex(hex::Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -192,7 +190,9 @@ impl PublicKey {
|
||||||
let compressed: bool = match data.len() {
|
let compressed: bool = match data.len() {
|
||||||
33 => true,
|
33 => true,
|
||||||
65 => false,
|
65 => false,
|
||||||
len => { return Err(base58::Error::InvalidLength(len).into()); },
|
len => {
|
||||||
|
return Err(base58::Error::InvalidLength(len).into());
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if !compressed && data[0] != 0x04 {
|
if !compressed && data[0] != 0x04 {
|
||||||
|
@ -323,13 +323,17 @@ impl PrivateKey {
|
||||||
let compressed = match data.len() {
|
let compressed = match data.len() {
|
||||||
33 => false,
|
33 => false,
|
||||||
34 => true,
|
34 => true,
|
||||||
_ => { return Err(Error::Base58(base58::Error::InvalidLength(data.len()))); }
|
_ => {
|
||||||
|
return Err(Error::Base58(base58::Error::InvalidLength(data.len())));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let network = match data[0] {
|
let network = match data[0] {
|
||||||
128 => Network::Bitcoin,
|
128 => Network::Bitcoin,
|
||||||
239 => Network::Testnet,
|
239 => Network::Testnet,
|
||||||
x => { return Err(Error::Base58(base58::Error::InvalidAddressVersion(x))); }
|
x => {
|
||||||
|
return Err(Error::Base58(base58::Error::InvalidAddressVersion(x)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(PrivateKey {
|
Ok(PrivateKey {
|
||||||
|
|
|
@ -217,8 +217,12 @@ mod message_signing {
|
||||||
/// instance of it, returning the number of instances removed.
|
/// instance of it, returning the number of instances removed.
|
||||||
/// Loops through the vector opcode by opcode, skipping pushed data.
|
/// Loops through the vector opcode by opcode, skipping pushed data.
|
||||||
pub fn script_find_and_remove(haystack: &mut Vec<u8>, needle: &[u8]) -> usize {
|
pub fn script_find_and_remove(haystack: &mut Vec<u8>, needle: &[u8]) -> usize {
|
||||||
if needle.len() > haystack.len() { return 0; }
|
if needle.len() > haystack.len() {
|
||||||
if needle.is_empty() { return 0; }
|
return 0;
|
||||||
|
}
|
||||||
|
if needle.is_empty() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
let mut top = haystack.len() - needle.len();
|
let mut top = haystack.len() - needle.len();
|
||||||
let mut n_deleted = 0;
|
let mut n_deleted = 0;
|
||||||
|
@ -233,7 +237,9 @@ pub fn script_find_and_remove(haystack: &mut Vec<u8>, needle: &[u8]) -> usize {
|
||||||
// This is ugly but prevents infinite loop in case of overflow
|
// This is ugly but prevents infinite loop in case of overflow
|
||||||
let overflow = top < needle.len();
|
let overflow = top < needle.len();
|
||||||
top = top.wrapping_sub(needle.len());
|
top = top.wrapping_sub(needle.len());
|
||||||
if overflow { break; }
|
if overflow {
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
i += match opcodes::All::from((*haystack)[i]).classify(opcodes::ClassifyContext::Legacy) {
|
i += match opcodes::All::from((*haystack)[i]).classify(opcodes::ClassifyContext::Legacy) {
|
||||||
opcodes::Class::PushBytes(n) => n as usize + 1,
|
opcodes::Class::PushBytes(n) => n as usize + 1,
|
||||||
|
|
|
@ -893,7 +893,6 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::serialize;
|
use super::serialize;
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_vectors() {
|
fn invalid_vectors() {
|
||||||
let err = hex_psbt!("70736274ff010071020000000127744ababf3027fe0d6cf23a96eee2efb188ef52301954585883e69b6624b2420000000000ffffffff02787c01000000000016001483a7e34bd99ff03a4962ef8a1a101bb295461ece606b042a010000001600147ac369df1b20e033d6116623957b0ac49f3c52e8000000000001012b00f2052a010000002251205a2c2cf5b52cf31f83ad2e8da63ff03183ecd8f609c7510ae8a48e03910a075701172102fe349064c98d6e2a853fa3c9b12bd8b304a19c195c60efa7ee2393046d3fa232000000").unwrap_err();
|
let err = hex_psbt!("70736274ff010071020000000127744ababf3027fe0d6cf23a96eee2efb188ef52301954585883e69b6624b2420000000000ffffffff02787c01000000000016001483a7e34bd99ff03a4962ef8a1a101bb295461ece606b042a010000001600147ac369df1b20e033d6116623957b0ac49f3c52e8000000000001012b00f2052a010000002251205a2c2cf5b52cf31f83ad2e8da63ff03183ecd8f609c7510ae8a48e03910a075701172102fe349064c98d6e2a853fa3c9b12bd8b304a19c195c60efa7ee2393046d3fa232000000").unwrap_err();
|
||||||
|
|
|
@ -169,7 +169,9 @@ macro_rules! construct_uint {
|
||||||
let &mut $name(ref mut arr) = self;
|
let &mut $name(ref mut arr) = self;
|
||||||
for i in 0..$n_words {
|
for i in 0..$n_words {
|
||||||
arr[i] = arr[i].wrapping_add(1);
|
arr[i] = arr[i].wrapping_add(1);
|
||||||
if arr[i] != 0 { break; }
|
if arr[i] != 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,8 +190,12 @@ macro_rules! construct_uint {
|
||||||
// and the auto derive is a lexicographic ordering(i.e. memcmp)
|
// and the auto derive is a lexicographic ordering(i.e. memcmp)
|
||||||
// which with numbers is equivalent to big-endian
|
// which with numbers is equivalent to big-endian
|
||||||
for i in 0..$n_words {
|
for i in 0..$n_words {
|
||||||
if self[$n_words - 1 - i] < other[$n_words - 1 - i] { return ::core::cmp::Ordering::Less; }
|
if self[$n_words - 1 - i] < other[$n_words - 1 - i] {
|
||||||
if self[$n_words - 1 - i] > other[$n_words - 1 - i] { return ::core::cmp::Ordering::Greater; }
|
return ::core::cmp::Ordering::Less;
|
||||||
|
}
|
||||||
|
if self[$n_words - 1 - i] > other[$n_words - 1 - i] {
|
||||||
|
return ::core::cmp::Ordering::Greater;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
::core::cmp::Ordering::Equal
|
::core::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue