Skip to content

Commit 701c9cc

Browse files
Remove un-necessary lifetimes
Remove lifetime parameter concerning `PkH(Pk::Hash)` to `PkH(Pk)` refactor.
1 parent ca16bd8 commit 701c9cc

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/interpreter/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,15 @@ where
590590
Terminal::PkK(ref pk) => {
591591
debug_assert_eq!(node_state.n_evaluated, 0);
592592
debug_assert_eq!(node_state.n_satisfied, 0);
593-
let res = self.stack.evaluate_pk(&mut self.verify_sig, pk);
593+
let res = self.stack.evaluate_pk(&mut self.verify_sig, *pk);
594594
if res.is_some() {
595595
return res;
596596
}
597597
}
598598
Terminal::PkH(ref pkh) => {
599599
debug_assert_eq!(node_state.n_evaluated, 0);
600600
debug_assert_eq!(node_state.n_satisfied, 0);
601-
let res = self.stack.evaluate_pkh(&mut self.verify_sig, pkh);
601+
let res = self.stack.evaluate_pkh(&mut self.verify_sig, *pkh);
602602
if res.is_some() {
603603
return res;
604604
}
@@ -857,7 +857,7 @@ where
857857
// push 1 on satisfied sigs and push 0 on empty sigs
858858
match self
859859
.stack
860-
.evaluate_pk(&mut self.verify_sig, &subs[node_state.n_evaluated])
860+
.evaluate_pk(&mut self.verify_sig, subs[node_state.n_evaluated])
861861
{
862862
Some(Ok(x)) => {
863863
self.push_evaluation_state(

src/interpreter/stack.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl<'txin> Stack<'txin> {
134134
pub(super) fn evaluate_pk<'intp>(
135135
&mut self,
136136
verify_sig: &mut Box<dyn FnMut(&KeySigPair) -> bool + 'intp>,
137-
pk: &'intp BitcoinKey,
137+
pk: BitcoinKey,
138138
) -> Option<Result<SatisfiedConstraint, Error>> {
139139
if let Some(sigser) = self.pop() {
140140
match sigser {
@@ -143,7 +143,7 @@ impl<'txin> Stack<'txin> {
143143
None
144144
}
145145
Element::Push(sigser) => {
146-
let key_sig = verify_sersig(verify_sig, pk, sigser);
146+
let key_sig = verify_sersig(verify_sig, &pk, sigser);
147147
match key_sig {
148148
Ok(key_sig) => {
149149
self.push(Element::Satisfied);
@@ -152,9 +152,7 @@ impl<'txin> Stack<'txin> {
152152
Err(e) => Some(Err(e)),
153153
}
154154
}
155-
Element::Satisfied => {
156-
Some(Err(Error::PkEvaluationError(PkEvalErrInner::from(*pk))))
157-
}
155+
Element::Satisfied => Some(Err(Error::PkEvaluationError(PkEvalErrInner::from(pk)))),
158156
}
159157
} else {
160158
Some(Err(Error::UnexpectedStackEnd))
@@ -170,7 +168,7 @@ impl<'txin> Stack<'txin> {
170168
pub(super) fn evaluate_pkh<'intp>(
171169
&mut self,
172170
verify_sig: &mut Box<dyn FnMut(&KeySigPair) -> bool + 'intp>,
173-
pkh: &'intp TypedHash160,
171+
pkh: TypedHash160,
174172
) -> Option<Result<SatisfiedConstraint, Error>> {
175173
// Parse a bitcoin key from witness data slice depending on hash context
176174
// when we encounter a pkh(hash)
@@ -189,7 +187,7 @@ impl<'txin> Stack<'txin> {
189187
if pk_hash != pkh.hash160() {
190188
return Some(Err(Error::PkHashVerifyFail(pkh.hash160())));
191189
}
192-
match bitcoin_key_from_slice(pk, *pkh) {
190+
match bitcoin_key_from_slice(pk, pkh) {
193191
Some(pk) => {
194192
if let Some(sigser) = self.pop() {
195193
match sigser {

0 commit comments

Comments
 (0)