Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

sdk/agent: add event handlers #242

Closed
wants to merge 2 commits into from
Closed

sdk/agent: add event handlers #242

wants to merge 2 commits into from

Conversation

leighmcculloch
Copy link
Contributor

@leighmcculloch leighmcculloch commented Aug 21, 2021

What

Add event handlers for the things that can occur in the background during open, payment, and close.

Why

The agent receives messages from the other participant containing confirmations/responses to requests made by this recipient, and requests from the other participant. Some of these operations that take place in the background need to be made known to the application using the agent.

The agent will also monitor the state of the network for changes that require action, and once that logic is added we'll need to add events using the same pattern.

Close #226

Known Limitations

This change is somewhat limited because some of the change depends on ingestion having been integrated into the agent, but I'm deferring doing that integration until the integration and state changes have been finished in the state package. Because of that there are some TODOs, but I think it is worth merging this and revisiting it during the ingestion work.

Base automatically changed from issue224 to main August 23, 2021 18:43
@leighmcculloch leighmcculloch changed the base branch from main to moveinit August 24, 2021 18:46
@leighmcculloch leighmcculloch linked an issue Aug 25, 2021 that may be closed by this pull request
Base automatically changed from moveinit to main August 25, 2021 16:50
@leighmcculloch leighmcculloch changed the base branch from main to underfundedagent August 26, 2021 06:31
@leighmcculloch leighmcculloch changed the base branch from underfundedagent to firsttest August 26, 2021 06:45
@leighmcculloch leighmcculloch changed the title sdk/agent: add event handlers (wip) sdk/agent: add event handlers Aug 26, 2021
@leighmcculloch leighmcculloch marked this pull request as ready for review August 26, 2021 06:46
leighmcculloch added a commit that referenced this pull request Aug 26, 2021
Update escrow account on-network balance that is cached in the channel whenever sending or receiving a payment that looks like it exceeds the last known available balance.

If a payment is exceeding the balance the only option we have is to stop and close the channel, so we may as check the network to see if the balance is updated which might allow the payment to succeed.

I think the usefulness of this balance update is questionable given we will soon have the agent using the state's ingestion to update the balances, but in the interim I need to update the balances one way or another to get tests I'm writing for #225 and #226 to pass. This seems like a good temporary hold over and something we can evaluate in the near future if we still need.

I removed the TODO to remove the existing check because it's a little fuzzy to me if we really want to do that.

There's no test in this PR for this change because I'm writing tests for the agent in #242 which incorporates a few things that make writing tests for the agent much more straight forward.
@leighmcculloch leighmcculloch marked this pull request as draft August 26, 2021 19:45
@leighmcculloch
Copy link
Contributor Author

Superseded by #257

@leighmcculloch leighmcculloch deleted the issue226 branch August 26, 2021 21:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sdk/agent: add event handlers for open, payment, close
1 participant