Change weight to call predict_weight
This commit is contained in:
parent
12e014e288
commit
80a4d692c4
|
@ -19,7 +19,6 @@ use hashes::{self, sha256d, Hash};
|
||||||
use internals::write_err;
|
use internals::write_err;
|
||||||
|
|
||||||
use super::Weight;
|
use super::Weight;
|
||||||
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
|
|
||||||
use crate::blockdata::locktime::absolute::{self, Height, Time};
|
use crate::blockdata::locktime::absolute::{self, Height, Time};
|
||||||
use crate::blockdata::locktime::relative;
|
use crate::blockdata::locktime::relative;
|
||||||
#[cfg(feature = "bitcoinconsensus")]
|
#[cfg(feature = "bitcoinconsensus")]
|
||||||
|
@ -838,7 +837,14 @@ impl Transaction {
|
||||||
/// and can therefore avoid this ambiguity.
|
/// and can therefore avoid this ambiguity.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn weight(&self) -> Weight {
|
pub fn weight(&self) -> Weight {
|
||||||
Weight::from_wu(self.scaled_size(WITNESS_SCALE_FACTOR) as u64)
|
let inputs = self.input.iter().map(|txin| {
|
||||||
|
InputWeightPrediction::new(
|
||||||
|
txin.script_sig.len(),
|
||||||
|
txin.witness.iter().map(|elem| elem.len()),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
let outputs = self.output.iter().map(|txout| txout.script_pubkey.len());
|
||||||
|
predict_weight(inputs, outputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the regular byte-wise consensus-serialized size of this transaction.
|
/// Returns the regular byte-wise consensus-serialized size of this transaction.
|
||||||
|
|
Loading…
Reference in New Issue