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

Always notify if a sendpay payment attempt is resolved #3405

Merged
merged 5 commits into from
Jan 13, 2020

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Jan 8, 2020

Sendpay notifications would get sent only if we have an active watcher, and multiple times if we have more than one watcher. This kind of defeats the point since we can't just fire and forget sendpay and wait for the notification if that notification is bound to the watchers.

This PR fixes that by pulling the notification out of the watcher loop, concentrating the error message allocation in a single place, and inverting ownership of wallet_payment_store. This also reduces a couple of useless allocations, since we don't store, free, then reload the wallet_payment anymore.

Fixes #3403

Copy link
Contributor

@ZmnSCPxj ZmnSCPxj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed the draftness a bit late, decided to just publish my comments anyway.

lightningd/pay.c Outdated Show resolved Hide resolved
lightningd/pay.c Outdated Show resolved Hide resolved
lightningd/pay.c Show resolved Hide resolved
Copy link
Member Author

@cdecker cdecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed the draftness a bit late, decided to just publish my comments anyway.

No worries, I was in a rush and didn't check my implementation of the inversion of ownership too well, so I just wanted to avoid this being merged before I can cross-check it once more :-)

Feedback is always welcome ^^

Copy link
Contributor

@ZmnSCPxj ZmnSCPxj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK dc694eb

@cdecker cdecker force-pushed the notify-sendpay branch 2 times, most recently from 8b465f8 to dd925d8 Compare January 11, 2020 15:13
@cdecker cdecker marked this pull request as ready for review January 11, 2020 15:15
Copy link
Contributor

@ZmnSCPxj ZmnSCPxj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some nits

lightningd/pay.c Outdated Show resolved Hide resolved
…ith no waiter

We clone the test above, but this time we don't attach waiters (they'd be racy
anyway), and we wait for the notification to be called. This fails, but is
fixed in the next two commits.
We're about to move it a bit up in the call-graph, so encapsulate it in its
own function.
Changelog-Changed: plugin: `notify_sendpay_success` and `notify_sendpay_failure` are now always called, even if there is no command waiting on the result.
`wallet_payment_store` frees the unstored payment after it has stored it, but
we still need that instance for our notifications. This is the smallest
possible fix, but I plan to refactor this out.
`wallet_payment_store` would free the `wallet_payment` instance which would
then cause us to reload it from the DB. Instead of doing the store->free->load
dance we now tell `wallet_payment_store` whether it should take ownership and
leave it alone if not.

Passing the payment around instead of referencing it through payment_hash and
partid is a nice side-effect.
Copy link
Contributor

@ZmnSCPxj ZmnSCPxj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e1264f7

@cdecker cdecker merged commit 4be1868 into ElementsProject:master Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sendpay notifications not sent unless we have at least one waiter
2 participants