Skip to content

Commit 1b49d43

Browse files
committed
replace VarInt::len with VarInt::size
1 parent 0d392dc commit 1b49d43

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl Block {
373373
/// Get the size of the block
374374
pub fn size(&self) -> usize {
375375
// The size of the header + the size of the varint with the tx count + the txs themselves
376-
let base_size = serialize(&self.header).len() + VarInt(self.txdata.len() as u64).len();
376+
let base_size = serialize(&self.header).len() + VarInt(self.txdata.len() as u64).size();
377377
let txs_size: usize = self.txdata.iter().map(Transaction::size).sum();
378378
base_size + txs_size
379379
}
@@ -386,7 +386,7 @@ impl Block {
386386

387387
/// Get the weight of the block
388388
pub fn weight(&self) -> usize {
389-
let base_weight = 4 * (serialize(&self.header).len() + VarInt(self.txdata.len() as u64).len());
389+
let base_weight = 4 * (serialize(&self.header).len() + VarInt(self.txdata.len() as u64).size());
390390
let txs_weight: usize = self.txdata.iter().map(Transaction::weight).sum();
391391
base_weight + txs_weight
392392
}

src/transaction.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ impl Transaction {
933933
let input_weight = self.input.iter().map(|input| {
934934
scale_factor * (
935935
32 + 4 + 4 + // output + nSequence
936-
VarInt(input.script_sig.len() as u64).len() +
936+
VarInt(input.script_sig.len() as u64).size() +
937937
input.script_sig.len() + if input.has_issuance() {
938938
64 +
939939
input.asset_issuance.amount.encoded_length() +
@@ -947,18 +947,18 @@ impl Transaction {
947947
let keys_prf_len = input.witness.inflation_keys_rangeproof.as_ref()
948948
.map(|x| x.len()).unwrap_or(0);
949949

950-
VarInt(amt_prf_len as u64).len() +
950+
VarInt(amt_prf_len as u64).size() +
951951
amt_prf_len +
952-
VarInt(keys_prf_len as u64).len() +
952+
VarInt(keys_prf_len as u64).size() +
953953
keys_prf_len +
954-
VarInt(input.witness.script_witness.len() as u64).len() +
954+
VarInt(input.witness.script_witness.len() as u64).size() +
955955
input.witness.script_witness.iter().map(|wit|
956-
VarInt(wit.len() as u64).len() +
956+
VarInt(wit.len() as u64).size() +
957957
wit.len()
958958
).sum::<usize>() +
959-
VarInt(input.witness.pegin_witness.len() as u64).len() +
959+
VarInt(input.witness.pegin_witness.len() as u64).size() +
960960
input.witness.pegin_witness.iter().map(|wit|
961-
VarInt(wit.len() as u64).len() +
961+
VarInt(wit.len() as u64).size() +
962962
wit.len()
963963
).sum::<usize>()
964964
} else {
@@ -971,14 +971,14 @@ impl Transaction {
971971
output.asset.encoded_length() +
972972
output.value.encoded_length() +
973973
output.nonce.encoded_length() +
974-
VarInt(output.script_pubkey.len() as u64).len() +
974+
VarInt(output.script_pubkey.len() as u64).size() +
975975
output.script_pubkey.len()
976976
) + if witness_flag {
977977
let range_prf_len = output.witness.rangeproof_len();
978978
let surj_prf_len = output.witness.surjectionproof_len();
979-
VarInt(surj_prf_len as u64).len() +
979+
VarInt(surj_prf_len as u64).size() +
980980
surj_prf_len +
981-
VarInt(range_prf_len as u64).len() +
981+
VarInt(range_prf_len as u64).size() +
982982
range_prf_len
983983
} else {
984984
0
@@ -988,8 +988,8 @@ impl Transaction {
988988
scale_factor * (
989989
4 + // version
990990
4 + // locktime
991-
VarInt(self.input.len() as u64).len() +
992-
VarInt(self.output.len() as u64).len() +
991+
VarInt(self.input.len() as u64).size() +
992+
VarInt(self.output.len() as u64).size() +
993993
1 // segwit flag byte (note this is *not* witness data in Elements)
994994
) + input_weight + output_weight
995995
}

0 commit comments

Comments
 (0)