-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat: store API launch discovery process if needed #2092
Conversation
You can find the image built from this PR at
Built from 77283f9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh, I'm not sure about moving the actual logic of doing the query from the API. It seems to me that this is exactly where the querying logic should reside. What would make more sense to me is introducing something like a peerSelector
function which gets passed down as an argument. WDYT?
I disagree, I did it this way because the REST related code should not be mixed with what the request actually do, that way in the future adding some other APIs would be much easier. Another benefit would be that tests can be separated too. API specific (request) -> app logic -> API specific (response) |
@SionoiS I would have a generic comment here and it is a WDYT. I'm ok and happy with peer selection delegated outside. But maybe I would rather have a standard peer selection that could be overwritten by the app writer if there are other demands than basic functionality. While moving away the knowledge of how to call the query is something is a bad idea. I'm thinking for a while and for me all these refactorings points to the direction that if we want to move functionalities from the node to app level, it would be better choice to introduce a mid layer, we can call it light_node/light_client. cc: @jm-clius, @Ivansete-status, @gabrielmer. /Maybe it could be better discussed on discord or under an gh issue.../ |
What if the closure was optional and defaulted to the logic in this PR?
Since the API calls have one purpose I don't see us changing the "interface" (closure's signature) often.
I don't see what this mid layer would be responsible for. 🤔 |
Exactly, we could have a default peer selection, that can be overridden by app writer person if needed.
I don't mean often, but in this place we outsource the mean of the client call (REST API) to the app. On contrary as if I were the one using waku as a communication core of my application I would be happy to get such services ready made. In this term I get a rest interface I can use to communicate with my app without being involved too much in tiny details. Of course there is no barrier that can prevent use of node's client interface.
Maybe I'm totally wrong with that design aim. For me all these layers are service layers. Node, API, ... |
An app that does not use discovery would not be able to use the APIs if discovery is internal to them.
Full vs Light node is tricky because it depends on which protocol the app uses. In Nim our choice of abstraction seams limited (only by my knowledge of Nim maybe). |
@jm-clius @NagyZoltanPeter Check #2109 as an alternative |
Description
First step in a refactor of the way external APIs work. REST APIs requests now trigger a handler from the app layer. This new handler is responsible for tying peer manager, discv5 and node. It returns the result of the request without any knowledge of the internals of the REST APIs.
Next step would be to do the same for all APIs.
I'm still not sure of the timeout. Is it long enough? Should we loop wait until a peer is found?
Maybe start searching for a peer but return an error right away. Asking the client to try again later?
Changes
app
that ties discv5, peer manager and nodeTracking #1941