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

Lnd manager #163

Merged
merged 14 commits into from
Sep 28, 2018
Merged

Lnd manager #163

merged 14 commits into from
Sep 28, 2018

Conversation

PirosB3
Copy link
Contributor

@PirosB3 PirosB3 commented Sep 23, 2018

This is a stepping stone in order to tackle #162. As of today, if the lightning RPC service disconnects, there is no way for the client to reconnect automatically and the only solution is to restart the server. This PR tries to address that by providing a wrapper around lightning that handles internal state

What does this PR address (in order of relevance)

  • refactors lightning into LightningManager class
  • refactors app/routes to use an instance of LightningManager, using a small adaptor
  • refactors other parts of the codebase to use an instance of LightningManager
  • adds documentation to the code refactored
  • reduces code duplication between server and server-le

Advice for reviewing this PR, where to start

  1. Start with LightningManager, and review how the external API (.call) is used
  2. Review lightningRPCAdapter function
  3. Review all the function signatures in app/routes to make sure they were refactored appropriately
  4. Review makeLightningManager server function
  5. Do a dry test of the application, all functionality should work

Apologies if I didn't respect a specific stile guide, since none was enforced in README or in the files. I'm definitely happy to refactor stile/documentation/anything to fit the projects needs. Let me know if I should be doing something differently :) I will happily adapt

@mably
Copy link
Owner

mably commented Sep 23, 2018

Looks good to me besides a few indentations that need to be fixed.

@PirosB3 PirosB3 mentioned this pull request Sep 28, 2018
@PirosB3
Copy link
Contributor Author

PirosB3 commented Sep 28, 2018

@mably thanks for the review. As suggested by you, I have implemented the Airbnb Style Guide that we will be using from now onwards (including the files in this PR). If you don't have any technical comments I would suggest:

  1. merge the PR
  2. I will open a PR containing the linting to master. This code not only provides the configuration for the style guide, but it also reformats app/lightning.js and app/routes using the new style guide.

Alternatively, I can close this PR and open one containing the style changes for these files, but the line count to review go up 2x :(

@mably mably merged commit acfa1f3 into mably:master Sep 28, 2018
@mably
Copy link
Owner

mably commented Sep 28, 2018

Merged. Thanks for your great work!

@mably
Copy link
Owner

mably commented Sep 29, 2018

Ok, just deployed it on some of my node and it looks like a few things are broken 😢

@mably
Copy link
Owner

mably commented Sep 29, 2018

@PirosB3 looks like error handling needs to be improved quickly, every error returns UNCATEGORIZED now.

@PirosB3
Copy link
Contributor Author

PirosB3 commented Sep 29, 2018 via email

@mably
Copy link
Owner

mably commented Sep 29, 2018

You just need to handle the gRPC as they were handled before, so the web front-end can display the correct error message to the user instead of a generic UNCATEGORIZED one.

@PirosB3
Copy link
Contributor Author

PirosB3 commented Sep 29, 2018 via email

break;
default:
logger.error("Unrecognized gRPC error: " + err);
reject(LightningError.UNCATEGORIZED);
Copy link
Owner

Choose a reason for hiding this comment

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

@PirosB3 looks like we are losing the original gRPC error here.
We need it to be able to handle it correctly on the web-client side.

@PirosB3
Copy link
Contributor Author

PirosB3 commented Sep 29, 2018 via email


} else {
// drop active client, so that it can be recreated
this.activeClient = null;
Copy link
Owner

Choose a reason for hiding this comment

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

@PirosB3 seems a bit excessive to me to drop the client on every gRPC error we are receiving 🤔

@mably
Copy link
Owner

mably commented Sep 29, 2018

Ok, no pb, you can work on it next week, I already fixed the most urgent issues.

@mably
Copy link
Owner

mably commented Oct 8, 2018

Pushed a quick hack to allow display of API errors in the web client: #177

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.

2 participants