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

External endpoint: /peers/connected #3362

Closed
wants to merge 1 commit into from
Closed

Conversation

uwiger
Copy link
Member

@uwiger uwiger commented Sep 24, 2020

See issue #3357

There is an internal endpoint, /debug/peers, which basically returns the same thing (at least the pubkeys of connected peers).
I added an external endpoint which returns an array of objects, currently containing pub_key, host and port of the relevant peers.

Example, from the new test aehttp_integration_SUITE:get_connected_peers/1:

connected_peers (dev1) = [{default,
                              {ok,200,
                                  #{<<"connected_peers">> =>
                                        [#{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3025,
                                           <<"pub_key">> =>
                                               <<"pp_23YdvfRPQ1b1AMWmkKZUGk2cQLqygQp55FzDWZSEUicPjhxtp5">>},
                                         #{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3035,
                                           <<"pub_key">> =>
                                               <<"pp_2M9oPohzsWgJrBBCFeYi3PVT4YF7F2botBtq6J1EGcVkiutx3R">>}]}}},
                          {all,
                              {ok,200,
                                  #{<<"connected_peers">> =>
                                        [#{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3025,
                                           <<"pub_key">> =>
                                               <<"pp_23YdvfRPQ1b1AMWmkKZUGk2cQLqygQp55FzDWZSEUicPjhxtp5">>},
                                         #{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3035,
                                           <<"pub_key">> =>
                                               <<"pp_2M9oPohzsWgJrBBCFeYi3PVT4YF7F2botBtq6J1EGcVkiutx3R">>}]}}},
                          {inbound,
                              {ok,200,
                                  #{<<"connected_peers">> =>
                                        [#{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3025,
                                           <<"pub_key">> =>
                                               <<"pp_23YdvfRPQ1b1AMWmkKZUGk2cQLqygQp55FzDWZSEUicPjhxtp5">>},
                                         #{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3035,
                                           <<"pub_key">> =>
                                               <<"pp_2M9oPohzsWgJrBBCFeYi3PVT4YF7F2botBtq6J1EGcVkiutx3R">>}]}}},
                          {outbound,
                              {ok,200,
                                  #{<<"connected_peers">> =>
                                        [#{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3025,
                                           <<"pub_key">> =>
                                               <<"pp_23YdvfRPQ1b1AMWmkKZUGk2cQLqygQp55FzDWZSEUicPjhxtp5">>},
                                         #{<<"host">> => <<"localhost">>,
                                           <<"port">> => 3035,
                                           <<"pub_key">> =>
                                               <<"pp_2M9oPohzsWgJrBBCFeYi3PVT4YF7F2botBtq6J1EGcVkiutx3R">>}]}}}]

I added a three-node configuration for the peer_endpoints test group, in preparation for further tests. Also, the peer pool persistence issue (#3356) may warrant other parameters for each peer, which could be added to the result.

Copy link
Contributor

@gorbak25 gorbak25 left a comment

Choose a reason for hiding this comment

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

Looks good but this PR doesn't resolve this issue.
What we need besides this PR is a /peers/all_peers endpoint(can be internal) which lists all peers in the pool - even the disconnected ones. Nodes might be connected only to a handful of peers.

@uwiger
Copy link
Member Author

uwiger commented Sep 25, 2020

What we need besides this PR is a /peers/all_peers endpoint(can be internal)

So taking /debug/peers as a starting point, what would you like to add?
It lists all connected peers, all inbound, all outbound and all blocked. Just the pubkeys.

Looking at the available peers api, we could also provide available_peers (verified | unverified | standby | hostnames), where hostnames are the ones that failed to resolve and are pending retry.

@gorbak25
Copy link
Contributor

gorbak25 commented Oct 9, 2020

  1. This endpoint should be disabled unless explicitly enabled by a user as it might be costly and might decrease the privacy of the network - this should only be enabled by nodes operated for monitoring the peers.
  2. Exposing data from aec_peers:connected_peers is useless for the intended usecase
    image

@uwiger
Copy link
Member Author

uwiger commented Jul 5, 2021

Not needed/desired. Closing.

@uwiger uwiger closed this Jul 5, 2021
@uwiger uwiger deleted the gh3357-peers-endpoints branch February 18, 2023 08:36
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.

None yet

2 participants