Take spent closure by value in count_witness_sigops and count_p2sh_sigops
This fixes issue #4141 Change count_witness_sigops and count_p2sh_sigops to take the spent closure by value instead of &mut - Changed both functions to accept S as a value (FnMut) instead of &mut S - Removes need to annotate &mut when calling the function
This commit is contained in:
parent
95c012ee53
commit
ae0ba6c135
|
@ -414,7 +414,7 @@ impl TransactionExt for Transaction {
|
||||||
|
|
||||||
// coinbase tx is correctly handled because `spent` will always returns None.
|
// coinbase tx is correctly handled because `spent` will always returns None.
|
||||||
cost = cost.saturating_add(self.count_p2sh_sigops(&mut spent).saturating_mul(4));
|
cost = cost.saturating_add(self.count_p2sh_sigops(&mut spent).saturating_mul(4));
|
||||||
cost.saturating_add(self.count_witness_sigops(&mut spent))
|
cost.saturating_add(self.count_witness_sigops(spent))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -453,12 +453,12 @@ trait TransactionExtPriv {
|
||||||
fn count_p2pk_p2pkh_sigops(&self) -> usize;
|
fn count_p2pk_p2pkh_sigops(&self) -> usize;
|
||||||
|
|
||||||
/// Does not include wrapped SegWit (see `count_witness_sigops`).
|
/// Does not include wrapped SegWit (see `count_witness_sigops`).
|
||||||
fn count_p2sh_sigops<S>(&self, spent: &mut S) -> usize
|
fn count_p2sh_sigops<S>(&self, spent: S) -> usize
|
||||||
where
|
where
|
||||||
S: FnMut(&OutPoint) -> Option<TxOut>;
|
S: FnMut(&OutPoint) -> Option<TxOut>;
|
||||||
|
|
||||||
/// Includes wrapped SegWit (returns 0 for Taproot spends).
|
/// Includes wrapped SegWit (returns 0 for Taproot spends).
|
||||||
fn count_witness_sigops<S>(&self, spent: &mut S) -> usize
|
fn count_witness_sigops<S>(&self, spent: S) -> usize
|
||||||
where
|
where
|
||||||
S: FnMut(&OutPoint) -> Option<TxOut>;
|
S: FnMut(&OutPoint) -> Option<TxOut>;
|
||||||
|
|
||||||
|
@ -481,7 +481,7 @@ impl TransactionExtPriv for Transaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Does not include wrapped SegWit (see `count_witness_sigops`).
|
/// Does not include wrapped SegWit (see `count_witness_sigops`).
|
||||||
fn count_p2sh_sigops<S>(&self, spent: &mut S) -> usize
|
fn count_p2sh_sigops<S>(&self, mut spent: S) -> usize
|
||||||
where
|
where
|
||||||
S: FnMut(&OutPoint) -> Option<TxOut>,
|
S: FnMut(&OutPoint) -> Option<TxOut>,
|
||||||
{
|
{
|
||||||
|
@ -506,7 +506,7 @@ impl TransactionExtPriv for Transaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Includes wrapped SegWit (returns 0 for Taproot spends).
|
/// Includes wrapped SegWit (returns 0 for Taproot spends).
|
||||||
fn count_witness_sigops<S>(&self, spent: &mut S) -> usize
|
fn count_witness_sigops<S>(&self, mut spent: S) -> usize
|
||||||
where
|
where
|
||||||
S: FnMut(&OutPoint) -> Option<TxOut>,
|
S: FnMut(&OutPoint) -> Option<TxOut>,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue