Put && operator at front of line

In an effort to make code containing multi-line logical AND clearer to
read put the operator at the start of the line.
This commit is contained in:
Tobin Harding 2022-01-25 09:57:48 +11:00
parent f5512c4931
commit e54a2d653b
2 changed files with 21 additions and 21 deletions

View File

@ -195,8 +195,8 @@ impl Block {
// commitment is in the last output that starts with below magic
if let Some(pos) = coinbase.output.iter()
.rposition(|o| {
o.script_pubkey.len () >= 38 &&
o.script_pubkey[0..6] == [0x6a, 0x24, 0xaa, 0x21, 0xa9, 0xed] }) {
o.script_pubkey.len () >= 38
&& o.script_pubkey[0..6] == [0x6a, 0x24, 0xaa, 0x21, 0xa9, 0xed] }) {
let commitment = WitnessCommitment::from_slice(&coinbase.output[pos].script_pubkey.as_bytes()[6..38]).unwrap();
// witness reserved value is in coinbase input witness
let witness_vec: Vec<_> = coinbase.input[0].witness.iter().collect();

View File

@ -420,21 +420,21 @@ impl Script {
/// Checks whether a script pubkey is a p2sh output
#[inline]
pub fn is_p2sh(&self) -> bool {
self.0.len() == 23 &&
self.0[0] == opcodes::all::OP_HASH160.into_u8() &&
self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8() &&
self.0[22] == opcodes::all::OP_EQUAL.into_u8()
self.0.len() == 23
&& self.0[0] == opcodes::all::OP_HASH160.into_u8()
&& self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8()
&& self.0[22] == opcodes::all::OP_EQUAL.into_u8()
}
/// Checks whether a script pubkey is a p2pkh output
#[inline]
pub fn is_p2pkh(&self) -> bool {
self.0.len() == 25 &&
self.0[0] == opcodes::all::OP_DUP.into_u8() &&
self.0[1] == opcodes::all::OP_HASH160.into_u8() &&
self.0[2] == opcodes::all::OP_PUSHBYTES_20.into_u8() &&
self.0[23] == opcodes::all::OP_EQUALVERIFY.into_u8() &&
self.0[24] == opcodes::all::OP_CHECKSIG.into_u8()
self.0.len() == 25
&& self.0[0] == opcodes::all::OP_DUP.into_u8()
&& self.0[1] == opcodes::all::OP_HASH160.into_u8()
&& self.0[2] == opcodes::all::OP_PUSHBYTES_20.into_u8()
&& self.0[23] == opcodes::all::OP_EQUALVERIFY.into_u8()
&& self.0[24] == opcodes::all::OP_CHECKSIG.into_u8()
}
/// Checks whether a script pubkey is a p2pk output
@ -476,25 +476,25 @@ impl Script {
/// Checks whether a script pubkey is a p2wsh output
#[inline]
pub fn is_v0_p2wsh(&self) -> bool {
self.0.len() == 34 &&
self.witness_version() == Some(WitnessVersion::V0) &&
self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
self.0.len() == 34
&& self.witness_version() == Some(WitnessVersion::V0)
&& self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
}
/// Checks whether a script pubkey is a p2wpkh output
#[inline]
pub fn is_v0_p2wpkh(&self) -> bool {
self.0.len() == 22 &&
self.witness_version() == Some(WitnessVersion::V0) &&
self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8()
self.0.len() == 22
&& self.witness_version() == Some(WitnessVersion::V0)
&& self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8()
}
/// Checks whether a script pubkey is a P2TR output
#[inline]
pub fn is_v1_p2tr(&self) -> bool {
self.0.len() == 34 &&
self.witness_version() == Some(WitnessVersion::V1) &&
self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
self.0.len() == 34
&& self.witness_version() == Some(WitnessVersion::V1)
&& self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
}
/// Check if this is an OP_RETURN output