Skip to content

Commit a574b1e

Browse files
authored
Merge pull request #179 from jrakibi/fix-track-payment
Update method parameter to take reference to PaymentHash
2 parents dc544fa + 9ad40a6 commit a574b1e

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

sim-lib/src/cln.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl LightningNode for ClnNode {
188188

189189
async fn track_payment(
190190
&mut self,
191-
hash: PaymentHash,
191+
hash: &PaymentHash,
192192
shutdown: Listener,
193193
) -> Result<PaymentResult, LightningError> {
194194
loop {

sim-lib/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub trait LightningNode: Send {
250250
/// Track a payment with the specified hash.
251251
async fn track_payment(
252252
&mut self,
253-
hash: PaymentHash,
253+
hash: &PaymentHash,
254254
shutdown: Listener,
255255
) -> Result<PaymentResult, LightningError>;
256256
/// Gets information on a specific node
@@ -1214,7 +1214,7 @@ async fn track_payment_result(
12141214
let res = match payment.hash {
12151215
Some(hash) => {
12161216
log::debug!("Tracking payment outcome for: {}.", hex::encode(hash.0));
1217-
let track_payment = node.track_payment(hash, listener.clone());
1217+
let track_payment = node.track_payment(&hash, listener.clone());
12181218

12191219
match track_payment.await {
12201220
Ok(res) => {

sim-lib/src/lnd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl LightningNode for LndNode {
175175

176176
async fn track_payment(
177177
&mut self,
178-
hash: PaymentHash,
178+
hash: &PaymentHash,
179179
shutdown: Listener,
180180
) -> Result<PaymentResult, LightningError> {
181181
let response = self

sim-lib/src/sim_node.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,10 @@ impl<T: SimNetwork> LightningNode for SimNode<'_, T> {
557557
/// provided is triggered. This call will fail if the hash provided was not obtained by calling send_payment first.
558558
async fn track_payment(
559559
&mut self,
560-
hash: PaymentHash,
560+
hash: &PaymentHash,
561561
listener: Listener,
562562
) -> Result<PaymentResult, LightningError> {
563-
match self.in_flight.remove(&hash) {
563+
match self.in_flight.remove(hash) {
564564
Some(receiver) => {
565565
select! {
566566
biased;
@@ -1491,13 +1491,13 @@ mod tests {
14911491
let (_, shutdown_listener) = triggered::trigger();
14921492

14931493
let result_1 = node
1494-
.track_payment(hash_1, shutdown_listener.clone())
1494+
.track_payment(&hash_1, shutdown_listener.clone())
14951495
.await
14961496
.unwrap();
14971497
assert!(matches!(result_1.payment_outcome, PaymentOutcome::Success));
14981498

14991499
let result_2 = node
1500-
.track_payment(hash_2, shutdown_listener.clone())
1500+
.track_payment(&hash_2, shutdown_listener.clone())
15011501
.await
15021502
.unwrap();
15031503
assert!(matches!(

0 commit comments

Comments
 (0)