Skip to content

Commit

Permalink
RPC/Sentry: Peers method (#102)
Browse files Browse the repository at this point in the history
Add a method to return information about all connected peers.
This is needed to implement admin_peers RPC call.
  • Loading branch information
battlmonstr authored Apr 25, 2022
1 parent 595814a commit d813255
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions p2psentry/sentry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ message MessagesRequest {
repeated MessageId ids = 1;
}

message PeersReply {
repeated types.PeerInfo peers = 1;
}

message PeerCountRequest {}

message PeerCountReply {uint64 count = 1;}
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 11 additions & 2 deletions remote/ethbackend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -179,3 +184,7 @@ message NodesInfoRequest {
message NodesInfoReply {
repeated types.NodeInfoReply nodesInfo = 1;
}

message PeersReply {
repeated types.PeerInfo peers = 1;
}
13 changes: 13 additions & 0 deletions types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit d813255

Please sign in to comment.