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

Add additional information to /node/allPeers and /node/connectedPeers #273

Open
cronicc opened this issue Aug 6, 2021 · 1 comment
Open

Comments

@cronicc
Copy link
Member

cronicc commented Aug 6, 2021

First we should check if both of these endpoints (/node/allPeers, /node/connectedPeers) are needed. Are they doing the exact same thing? If yes remove one of them.

Secondly, exposing additional information about peers would be very useful. This is the current schema:

{
 "result": {
   "peers": [
     {
       "address": "string",
       "lastSeen": 0,
       "name": "string",
       "connectionType": "string"
     }
   ]
 },
 "error": {
   "code": "string",
   "description": "string",
   "detail": "string"
 }
}

And here is an example of information exposed from the mainchain getpeerinfo RPC:

  {
   "id": 30608,
   "addr": "remoteIP:remotePORT",
   "addrlocal": "localIP:localPORT",
   "services": "0000000000000001",
   "tls_established": true,
   "tls_verified": true,
   "lastsend": 1628245586,
   "lastrecv": 1628245584,
   "bytessent": 2734975,
   "bytesrecv": 298873,
   "conntime": 1628238954,
   "timeoffset": 0,
   "pingtime": 0.026836,
   "version": 170002,
   "subver": "/zen:2.0.23/",
   "inbound": true,
   "startingheight": 980646,
   "banscore": 0,
   "synced_headers": 980664,
   "synced_blocks": 980664,
   "inflight": [
   ],
   "whitelisted": false
 },

Extending the SC schema with this additional information would be of particular interest:

  • local and remote address
  • local and remote port (helps in detecting the connection on the OS level and with e.g. tcpdump)
  • lastsend/lastrecv timestamps
  • bytessent/bytesrecv or if not available the number of exchanged in/out messages
  • conntime
  • pingtime (if ping/pong are implemented)
  • information about client/protocol version
  • startingheight and synced_blocks
@paologalligit
Copy link
Contributor

First we should check if both of these endpoints (/node/allPeers, /node/connectedPeers) are needed. Are they doing the exact same thing? If yes remove one of them.

The endpoints are showing different things:

  • allPeers -> are all the peers that the node knows about and considers as good peers;
  • connectedPeers -> are all the peers the node is actively exchanging data with.

So there can be a scenario when the node wants to connect to a peer (visible in allPeers) but this one won't accept the connection, so it's not listed by the connectedPeers endpoint.

Secondly, exposing additional information about peers would be very useful.

With some little tweaks we can add:

  • local and remote address;
  • local and remote port;
  • information about client/protocol version.

All other data will require more work to be included: do we need all the items in the bullet points to be included in the response?

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

No branches or pull requests

2 participants