Skip to content

Commit 3e0db90

Browse files
committed
Add vsize
1 parent 0c8fb64 commit 3e0db90

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/transaction.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,15 @@ impl Transaction {
869869
self.scaled_size(1)
870870
}
871871

872+
/// Returns the "virtual size" (vsize) of this transaction.
873+
///
874+
/// Will be `ceil(weight / 4.0)`.
875+
#[inline]
876+
pub fn vsize(&self) -> usize {
877+
let weight = self.weight();
878+
(weight + 4 - 1) / 4
879+
}
880+
872881
fn scaled_size(&self, scale_factor: usize) -> usize {
873882
let witness_flag = self.has_witness();
874883

0 commit comments

Comments
 (0)