-
Notifications
You must be signed in to change notification settings - Fork 166
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 peer endpoints #101
Conversation
Do we really want pagination in this API? What is the use case for fetching an arbitrary subset of peers? |
you are suppose to include disconnected peers as well, it could be response with 500-600 peers or even more on mainnet |
Surely that is an argument to have filtering, not pagination. |
On what fields would you filter? Let's say I want all disconnected outgoing peers, that could still be 300 responses |
Yes, but if that is the information you want then why receive it piecemeal going through multiple requests rather than all in one response? From my experience, pagination is useful when results are ordered and end-user facing. For example, if someone wanted to list validators ordered by balance it's possible they are doing so to just see the first x validators, in which pagination makes sense because the user may well stop at page 1 or 2 of several hundred. However, if the common requirement is to obtain all results, possibly restricted by filter, I don't see the benefit of doing this. A good example of where this caused problems was in the beacon chain explorers recently. They use the prysm API to fetch validators, and it's paginated. The APi is by default limited to 250 responses, so the explorer required around 300 calls to obtain the data. The problem was that fetching validators for a non-head state required recreating the state from the last checkpoint, so what happened was:
This caused the explorers to be unable to provide information. It could be possible to cache the data, but then you're in to a world of second-guessing which results are going to be requested again, cache management, and all that fun. All that said, if client teams want to build pagination in to their APIs that's up to them. But if it's going to happen I'd far rather it was purely optional, and standard across all APIs (perhaps by adding generic |
Originally I was concerned about there not being an endpoint for peer count. I imagine there are going to be a lot of applications wanting to know how many connected peers a client has. If I've understood the current API's correctly, in order to do that, they have to receive all the data for all peers the client currently knows about and then filter. I would imagine they would poll regularly for this. Perhaps we have a peer_count endpoint which can have the queries |
Or not take a query and return the number in each state, which could be easier on the implementer. |
I don't really see a need for ordering by |
As per comments here, removed pagination and peer ordering. I've added peer filtering by connection direction and state. Since we cannot really have |
What about Or maybe we could add it to I'm not too concerned either way. Just some suggestions. I assume its something that would get polled regularly for misc applications. |
A separate
(As an aside, we should specify all possible states somewhere). |
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.
looks good, quick question and a minor copy suggestion
@mpetrunic I still see a |
Seems like I forgot to remove it. Yeah it should always be length of list |
Breaking:
peer.address -> peer.last_seen_p2p_address
Added clarifications and examples from #97
@AgeManning is this ok?
resolves #97