Indent functions

This fixes indentatiion that was intentionally "messed up" to make code
review easier.
This commit is contained in:
Martin Habovstiak 2023-03-16 20:12:58 +01:00
parent d56d202aeb
commit 00b46d6d9d
2 changed files with 33 additions and 33 deletions

View File

@ -1251,25 +1251,25 @@ pub fn predict_weight<I, O>(inputs: I, output_script_lens: O) -> Weight
} }
crate::internal_macros::maybe_const_fn! { crate::internal_macros::maybe_const_fn! {
fn predict_weight_internal(input_count: usize, partial_input_weight: usize, inputs_with_witnesses: usize, output_count: usize, output_scripts_size: usize) -> Weight { fn predict_weight_internal(input_count: usize, partial_input_weight: usize, inputs_with_witnesses: usize, output_count: usize, output_scripts_size: usize) -> Weight {
let input_weight = partial_input_weight + input_count * 4 * (32 + 4 + 4); let input_weight = partial_input_weight + input_count * 4 * (32 + 4 + 4);
let output_size = 8 * output_count + output_scripts_size; let output_size = 8 * output_count + output_scripts_size;
let non_input_size = let non_input_size =
// version: // version:
4 + 4 +
// count varints: // count varints:
VarInt(input_count as u64).len() + VarInt(input_count as u64).len() +
VarInt(output_count as u64).len() + VarInt(output_count as u64).len() +
output_size + output_size +
// lock_time // lock_time
4; 4;
let weight = if inputs_with_witnesses == 0 { let weight = if inputs_with_witnesses == 0 {
non_input_size * 4 + input_weight non_input_size * 4 + input_weight
} else { } else {
non_input_size * 4 + input_weight + input_count - inputs_with_witnesses + 2 non_input_size * 4 + input_weight + input_count - inputs_with_witnesses + 2
}; };
Weight::from_wu(weight as u64) Weight::from_wu(weight as u64)
} }
} }
/// Predicts the weight of a to-be-constructed transaction in const context. /// Predicts the weight of a to-be-constructed transaction in const context.

View File

@ -373,22 +373,22 @@ impl_int_encodable!(i64, read_i64, emit_i64);
#[allow(clippy::len_without_is_empty)] // VarInt has on concept of 'is_empty'. #[allow(clippy::len_without_is_empty)] // VarInt has on concept of 'is_empty'.
impl VarInt { impl VarInt {
crate::internal_macros::maybe_const_fn! { crate::internal_macros::maybe_const_fn! {
/// Gets the length of this VarInt when encoded. /// Gets the length of this VarInt when encoded.
/// ///
/// *Important: this method is only `const` in Rust 1.46 or higher!* /// *Important: this method is only `const` in Rust 1.46 or higher!*
/// ///
/// Returns 1 for 0..=0xFC, 3 for 0xFD..=(2^16-1), 5 for 0x10000..=(2^32-1), /// Returns 1 for 0..=0xFC, 3 for 0xFD..=(2^16-1), 5 for 0x10000..=(2^32-1),
/// and 9 otherwise. /// and 9 otherwise.
#[inline] #[inline]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
match self.0 { match self.0 {
0..=0xFC => { 1 } 0..=0xFC => { 1 }
0xFD..=0xFFFF => { 3 } 0xFD..=0xFFFF => { 3 }
0x10000..=0xFFFFFFFF => { 5 } 0x10000..=0xFFFFFFFF => { 5 }
_ => { 9 } _ => { 9 }
}
} }
} }
}
} }
impl Encodable for VarInt { impl Encodable for VarInt {