From ef01f4d0f6d5051e28593c4d2427537be56b7c7b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 2 Dec 2022 14:37:50 +1100 Subject: [PATCH] consensus: Introduce local variables In preparation for running the formatter introduce a couple of local variables to reduce the line length and inhibit function call from being split over multiple lines. Refactor only, no logic changes. --- bitcoin/src/consensus/encode.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bitcoin/src/consensus/encode.rs b/bitcoin/src/consensus/encode.rs index c6c83717..d8619578 100644 --- a/bitcoin/src/consensus/encode.rs +++ b/bitcoin/src/consensus/encode.rs @@ -652,7 +652,8 @@ impl Decodable for Vec { fn consensus_decode_from_finite_reader(r: &mut R) -> Result { let len = VarInt::consensus_decode(r)?.0 as usize; // most real-world vec of bytes data, wouldn't be larger than 128KiB - read_bytes_from_finite_reader(r, ReadBytesFromFiniteReaderOpts { len, chunk_size: 128 * 1024 }) + let opts = ReadBytesFromFiniteReaderOpts { len, chunk_size: 128 * 1024 }; + read_bytes_from_finite_reader(r, opts) } } @@ -693,7 +694,8 @@ impl Decodable for CheckedData { let len = u32::consensus_decode_from_finite_reader(r)? as usize; let checksum = <[u8; 4]>::consensus_decode_from_finite_reader(r)?; - let ret = read_bytes_from_finite_reader(r, ReadBytesFromFiniteReaderOpts { len, chunk_size: MAX_VEC_SIZE })?; + let opts = ReadBytesFromFiniteReaderOpts { len, chunk_size: MAX_VEC_SIZE }; + let ret = read_bytes_from_finite_reader(r, opts)?; let expected_checksum = sha2_checksum(&ret); if expected_checksum != checksum { Err(self::Error::InvalidChecksum {