Skip to content

Commit

Permalink
Merge pull request #179 from jrakibi/fix-track-payment
Browse files Browse the repository at this point in the history
Update method parameter to take reference to PaymentHash
  • Loading branch information
carlaKC authored Apr 22, 2024
2 parents dc544fa + 9ad40a6 commit a574b1e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sim-lib/src/cln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl LightningNode for ClnNode {

async fn track_payment(
&mut self,
hash: PaymentHash,
hash: &PaymentHash,
shutdown: Listener,
) -> Result<PaymentResult, LightningError> {
loop {
Expand Down
4 changes: 2 additions & 2 deletions sim-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub trait LightningNode: Send {
/// Track a payment with the specified hash.
async fn track_payment(
&mut self,
hash: PaymentHash,
hash: &PaymentHash,
shutdown: Listener,
) -> Result<PaymentResult, LightningError>;
/// Gets information on a specific node
Expand Down Expand Up @@ -1214,7 +1214,7 @@ async fn track_payment_result(
let res = match payment.hash {
Some(hash) => {
log::debug!("Tracking payment outcome for: {}.", hex::encode(hash.0));
let track_payment = node.track_payment(hash, listener.clone());
let track_payment = node.track_payment(&hash, listener.clone());

match track_payment.await {
Ok(res) => {
Expand Down
2 changes: 1 addition & 1 deletion sim-lib/src/lnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl LightningNode for LndNode {

async fn track_payment(
&mut self,
hash: PaymentHash,
hash: &PaymentHash,
shutdown: Listener,
) -> Result<PaymentResult, LightningError> {
let response = self
Expand Down
8 changes: 4 additions & 4 deletions sim-lib/src/sim_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,10 @@ impl<T: SimNetwork> LightningNode for SimNode<'_, T> {
/// provided is triggered. This call will fail if the hash provided was not obtained by calling send_payment first.
async fn track_payment(
&mut self,
hash: PaymentHash,
hash: &PaymentHash,
listener: Listener,
) -> Result<PaymentResult, LightningError> {
match self.in_flight.remove(&hash) {
match self.in_flight.remove(hash) {
Some(receiver) => {
select! {
biased;
Expand Down Expand Up @@ -1491,13 +1491,13 @@ mod tests {
let (_, shutdown_listener) = triggered::trigger();

let result_1 = node
.track_payment(hash_1, shutdown_listener.clone())
.track_payment(&hash_1, shutdown_listener.clone())
.await
.unwrap();
assert!(matches!(result_1.payment_outcome, PaymentOutcome::Success));

let result_2 = node
.track_payment(hash_2, shutdown_listener.clone())
.track_payment(&hash_2, shutdown_listener.clone())
.await
.unwrap();
assert!(matches!(
Expand Down

0 comments on commit a574b1e

Please sign in to comment.