Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update method parameter to take reference to PaymentHash #179

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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