Skip to content

Commit

Permalink
Deprecate function
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Nov 12, 2024
1 parent 1db4b72 commit 5b8e277
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bitcoin/src/blockdata/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ crate::internal_macros::define_extension_trait! {
///
/// Base weight excludes the witness and script.
// We need to use this const here but do not want to make it public in `primitives::TxIn`.
// note: unwrap cannot panic given the size of OutPoint and Seequence.
const TX_IN_BASE_WEIGHT: Weight =
Weight::from_vb_unwrap(OutPoint::SIZE as u64 + Sequence::SIZE as u64);
Weight::from_vb(OutPoint::SIZE as u64 + Sequence::SIZE as u64).unwrap();

crate::internal_macros::define_extension_trait! {
/// Extension functionality for the [`TxIn`] type.
Expand Down
3 changes: 2 additions & 1 deletion units/src/weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl Weight {
/// # Panics
///
/// If the conversion from virtual bytes overflows.
#[deprecated(since = "0.33.0", note = "use `from_vb` instead")]
pub const fn from_vb_unwrap(vb: u64) -> Weight {
match vb.checked_mul(Self::WITNESS_SCALE_FACTOR) {
Some(weight) => Weight(weight),
Expand Down Expand Up @@ -250,7 +251,7 @@ mod tests {

#[test]
fn from_vb_const() {
const WU: Weight = Weight::from_vb_unwrap(1);
const WU: Weight = Weight::from_vb(1).unwrap();
assert_eq!(Weight(4), WU);
}

Expand Down

0 comments on commit 5b8e277

Please sign in to comment.