From 59704033af0374d07016a9678ce38f47534a015e Mon Sep 17 00:00:00 2001 From: battlmonstr Date: Mon, 25 Apr 2022 14:15:25 +0200 Subject: [PATCH] RPC/Sentry: Peers method Add a method to return information about all connected peers. This is needed to implement admin_peers RPC call. --- p2psentry/sentry.proto | 5 +++++ remote/ethbackend.proto | 13 +++++++++++-- types/types.proto | 13 +++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/p2psentry/sentry.proto b/p2psentry/sentry.proto index 10fc29f..f8af51a 100644 --- a/p2psentry/sentry.proto +++ b/p2psentry/sentry.proto @@ -123,6 +123,10 @@ message MessagesRequest { repeated MessageId ids = 1; } +message PeersReply { + repeated types.PeerInfo peers = 1; +} + message PeerCountRequest {} message PeerCountReply {uint64 count = 1;} @@ -159,6 +163,7 @@ service Sentry { // It is possible to subscribe to the same set if ids more than once. rpc Messages(MessagesRequest) returns (stream InboundMessage); + rpc Peers(google.protobuf.Empty) returns (PeersReply); rpc PeerCount(PeerCountRequest) returns (PeerCountReply); // Subscribe to notifications about connected or lost peers. rpc PeerEvents(PeerEventsRequest) returns (stream PeerEvent); diff --git a/remote/ethbackend.proto b/remote/ethbackend.proto index ed17921..6df5e7e 100644 --- a/remote/ethbackend.proto +++ b/remote/ethbackend.proto @@ -47,11 +47,16 @@ service ETHBACKEND { // it doesn't provide consistency // Request fields are optional - it's ok to request block only by hash or only by number rpc Block(BlockRequest) returns (BlockReply); + // High-level method - can find block number by txn hash // it doesn't provide consistency rpc TxnLookup(TxnLookupRequest) returns (TxnLookupReply); - // NodeInfo collects and returns NodeInfo from all running celery instances. - rpc NodeInfo(NodesInfoRequest) returns(NodesInfoReply); + + // NodeInfo collects and returns NodeInfo from all running sentry instances. + rpc NodeInfo(NodesInfoRequest) returns (NodesInfoReply); + + // Peers collects and returns peers information from all running sentry instances. + rpc Peers(google.protobuf.Empty) returns (PeersReply); } enum Event { @@ -179,3 +184,7 @@ message NodesInfoRequest { message NodesInfoReply { repeated types.NodeInfoReply nodesInfo = 1; } + +message PeersReply { + repeated types.PeerInfo peers = 1; +} diff --git a/types/types.proto b/types/types.proto index 374cfe1..876d62d 100644 --- a/types/types.proto +++ b/types/types.proto @@ -89,3 +89,16 @@ message NodeInfoReply { string listenerAddr = 6; bytes protocols = 7; } + +message PeerInfo { + string id = 1; + string name = 2; + string enode = 3; + string enr = 4; + repeated string caps = 5; + string connLocalAddr = 6; + string connRemoteAddr = 7; + bool connIsInbound = 8; + bool connIsTrusted = 9; + bool connIsStatic = 10; +}