Skip to content

Commit dcd44a2

Browse files
committed
Remove redundant clones
1 parent 5839d20 commit dcd44a2

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

payjoin-cli/src/app/v2/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl App {
195195
SendSession::V2GetContext(context) =>
196196
self.get_proposed_payjoin_psbt(context, persister).await?,
197197
SendSession::ProposalReceived(proposal) => {
198-
self.process_pj_response(proposal.clone())?;
198+
self.process_pj_response(proposal)?;
199199
return Ok(());
200200
}
201201
_ => return Err(anyhow!("Unexpected sender state")),
@@ -232,7 +232,7 @@ impl App {
232232
match res {
233233
Ok(OptionalTransitionOutcome::Progress(psbt)) => {
234234
println!("Proposal received. Processing...");
235-
self.process_pj_response(psbt.clone())?;
235+
self.process_pj_response(psbt)?;
236236
return Ok(());
237237
}
238238
Ok(OptionalTransitionOutcome::Stasis(current_state)) => {
@@ -446,7 +446,7 @@ impl App {
446446
proposal.process_res(&res.bytes().await?, ohttp_ctx).save(persister)?;
447447
println!(
448448
"Response successful. Watch mempool for successful Payjoin. TXID: {}",
449-
payjoin_psbt.extract_tx_unchecked_fee_rate().clone().compute_txid()
449+
payjoin_psbt.extract_tx_unchecked_fee_rate().compute_txid()
450450
);
451451
Ok(())
452452
}

payjoin-cli/src/db/v2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ impl SenderPersister {
4242
send_tree.insert(id.as_ref(), value.as_slice())?;
4343
send_tree.flush()?;
4444

45-
Ok(Self { db: db.clone(), session_id: id })
45+
Ok(Self { db, session_id: id })
4646
}
4747

4848
pub fn from_id(db: Arc<Database>, id: SessionId) -> crate::db::Result<Self> {
49-
Ok(Self { db: db.clone(), session_id: id })
49+
Ok(Self { db, session_id: id })
5050
}
5151
}
5252

@@ -112,11 +112,11 @@ impl ReceiverPersister {
112112
recv_tree.insert(id.as_ref(), value.as_slice())?;
113113
recv_tree.flush()?;
114114

115-
Ok(Self { db: db.clone(), session_id: id })
115+
Ok(Self { db, session_id: id })
116116
}
117117

118118
pub fn from_id(db: Arc<Database>, id: SessionId) -> crate::db::Result<Self> {
119-
Ok(Self { db: db.clone(), session_id: id })
119+
Ok(Self { db, session_id: id })
120120
}
121121
}
122122

payjoin/src/core/receive/v2/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl Receiver<Initialized> {
405405
let new_state = Receiver {
406406
state: UncheckedProposal {
407407
v1: event,
408-
context: SessionContext { e: reply_key, ..self.state.context.clone() },
408+
context: SessionContext { e: reply_key, ..self.state.context },
409409
},
410410
};
411411

@@ -479,7 +479,7 @@ impl Receiver<UncheckedProposal> {
479479

480480
pub(crate) fn apply_maybe_inputs_owned(self, v1: v1::MaybeInputsOwned) -> ReceiveSession {
481481
let new_state =
482-
Receiver { state: MaybeInputsOwned { v1, context: self.state.context.clone() } };
482+
Receiver { state: MaybeInputsOwned { v1, context: self.state.context } };
483483
ReceiveSession::MaybeInputsOwned(new_state)
484484
}
485485
}
@@ -532,7 +532,7 @@ impl Receiver<MaybeInputsOwned> {
532532

533533
pub(crate) fn apply_maybe_inputs_seen(self, v1: v1::MaybeInputsSeen) -> ReceiveSession {
534534
let new_state =
535-
Receiver { state: MaybeInputsSeen { v1, context: self.state.context.clone() } };
535+
Receiver { state: MaybeInputsSeen { v1, context: self.state.context } };
536536
ReceiveSession::MaybeInputsSeen(new_state)
537537
}
538538
}
@@ -572,13 +572,13 @@ impl Receiver<MaybeInputsSeen> {
572572
};
573573
MaybeFatalTransition::success(
574574
SessionEvent::OutputsUnknown(inner.clone()),
575-
Receiver { state: OutputsUnknown { inner, context: self.state.context.clone() } },
575+
Receiver { state: OutputsUnknown { inner, context: self.state.context } },
576576
)
577577
}
578578

579579
pub(crate) fn apply_outputs_unknown(self, inner: v1::OutputsUnknown) -> ReceiveSession {
580580
let new_state =
581-
Receiver { state: OutputsUnknown { inner, context: self.state.context.clone() } };
581+
Receiver { state: OutputsUnknown { inner, context: self.state.context } };
582582
ReceiveSession::OutputsUnknown(new_state)
583583
}
584584
}
@@ -617,13 +617,13 @@ impl Receiver<OutputsUnknown> {
617617
};
618618
MaybeFatalTransition::success(
619619
SessionEvent::WantsOutputs(inner.clone()),
620-
Receiver { state: WantsOutputs { v1: inner, context: self.state.context.clone() } },
620+
Receiver { state: WantsOutputs { v1: inner, context: self.state.context } },
621621
)
622622
}
623623

624624
pub(crate) fn apply_wants_outputs(self, v1: v1::WantsOutputs) -> ReceiveSession {
625625
let new_state =
626-
Receiver { state: WantsOutputs { v1, context: self.state.context.clone() } };
626+
Receiver { state: WantsOutputs { v1, context: self.state.context } };
627627
ReceiveSession::WantsOutputs(new_state)
628628
}
629629
}
@@ -672,12 +672,12 @@ impl Receiver<WantsOutputs> {
672672
let inner = self.state.v1.clone().commit_outputs();
673673
NextStateTransition::success(
674674
SessionEvent::WantsInputs(inner.clone()),
675-
Receiver { state: WantsInputs { v1: inner, context: self.state.context.clone() } },
675+
Receiver { state: WantsInputs { v1: inner, context: self.state.context } },
676676
)
677677
}
678678

679679
pub(crate) fn apply_wants_inputs(self, v1: v1::WantsInputs) -> ReceiveSession {
680-
let new_state = Receiver { state: WantsInputs { v1, context: self.state.context.clone() } };
680+
let new_state = Receiver { state: WantsInputs { v1, context: self.state.context } };
681681
ReceiveSession::WantsInputs(new_state)
682682
}
683683
}
@@ -729,14 +729,14 @@ impl Receiver<WantsInputs> {
729729
NextStateTransition::success(
730730
SessionEvent::ProvisionalProposal(inner.clone()),
731731
Receiver {
732-
state: ProvisionalProposal { v1: inner, context: self.state.context.clone() },
732+
state: ProvisionalProposal { v1: inner, context: self.state.context },
733733
},
734734
)
735735
}
736736

737737
pub(crate) fn apply_provisional_proposal(self, v1: v1::ProvisionalProposal) -> ReceiveSession {
738738
let new_state =
739-
Receiver { state: ProvisionalProposal { v1, context: self.state.context.clone() } };
739+
Receiver { state: ProvisionalProposal { v1, context: self.state.context } };
740740
ReceiveSession::ProvisionalProposal(new_state)
741741
}
742742
}
@@ -780,13 +780,13 @@ impl Receiver<ProvisionalProposal> {
780780
};
781781
MaybeTransientTransition::success(
782782
SessionEvent::PayjoinProposal(inner.clone()),
783-
Receiver { state: PayjoinProposal { v1: inner, context: self.state.context.clone() } },
783+
Receiver { state: PayjoinProposal { v1: inner, context: self.state.context } },
784784
)
785785
}
786786

787787
pub(crate) fn apply_payjoin_proposal(self, v1: v1::PayjoinProposal) -> ReceiveSession {
788788
let new_state =
789-
Receiver { state: PayjoinProposal { v1, context: self.state.context.clone() } };
789+
Receiver { state: PayjoinProposal { v1, context: self.state.context } };
790790
ReceiveSession::PayjoinProposal(new_state)
791791
}
792792
}
@@ -904,7 +904,7 @@ pub(crate) fn pj_uri<'a>(
904904
) -> crate::PjUri<'a> {
905905
use crate::uri::{PayjoinExtras, UrlExt};
906906
let id = session_context.id();
907-
let mut pj = subdir(&session_context.directory, &id).clone();
907+
let mut pj = subdir(&session_context.directory, &id);
908908
pj.set_receiver_pubkey(session_context.s.public_key().clone());
909909
pj.set_ohttp(session_context.ohttp_keys.clone());
910910
pj.set_exp(session_context.expiry);

0 commit comments

Comments
 (0)