Optimize `Transaction.get_vsize()` (thanks @TheBlueMatt).

This commit is contained in:
Vis Virial 2021-06-29 07:14:01 +09:00
parent 2085dc32a7
commit 1bf9147a6e
No known key found for this signature in database
GPG Key ID: 7CAA10504DE829B9
1 changed files with 1 additions and 1 deletions

View File

@ -430,7 +430,7 @@ impl Transaction {
#[inline]
pub fn get_vsize(&self) -> usize {
let weight = self.get_weight();
(weight / WITNESS_SCALE_FACTOR) + if weight % WITNESS_SCALE_FACTOR == 0 { 0 } else { 1 }
(weight + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR
}
/// Internal utility function for get_{size,weight}