parent
ee9f4a2e3f
commit
e813111b3b
|
@ -705,6 +705,22 @@ proc installDebugApiHandlers(rpcServer: RpcServer, node: BeaconNode) =
|
|||
|
||||
return res
|
||||
|
||||
rpcServer.rpc("peers") do () -> JsonNode:
|
||||
var res = newJObject()
|
||||
var peers = newJArray()
|
||||
for id, peer in node.network.peerPool:
|
||||
peers.add(
|
||||
%(
|
||||
info: shortLog(peer.info),
|
||||
wasDialed: peer.wasDialed,
|
||||
connectionState: $peer.connectionState,
|
||||
score: peer.score,
|
||||
)
|
||||
)
|
||||
res.add("peers", peers)
|
||||
|
||||
return res
|
||||
|
||||
proc installRpcHandlers(rpcServer: RpcServer, node: BeaconNode) =
|
||||
rpcServer.installValidatorApiHandlers(node)
|
||||
rpcServer.installBeaconApiHandlers(node)
|
||||
|
|
|
@ -192,8 +192,6 @@ const
|
|||
TTFB_TIMEOUT* = 5.seconds
|
||||
RESP_TIMEOUT* = 10.seconds
|
||||
|
||||
readTimeoutErrorMsg = "Exceeded read timeout for a request"
|
||||
|
||||
NewPeerScore* = 200
|
||||
## Score which will be assigned to new connected Peer
|
||||
PeerScoreLowLimit* = 0
|
||||
|
@ -274,10 +272,6 @@ proc openStream(node: Eth2Node,
|
|||
else:
|
||||
raise
|
||||
|
||||
func peerId(conn: Connection): PeerID =
|
||||
# TODO: Can this be `nil`?
|
||||
conn.peerInfo.peerId
|
||||
|
||||
proc init*(T: type Peer, network: Eth2Node, info: PeerInfo): Peer {.gcsafe.}
|
||||
|
||||
proc getPeer*(node: Eth2Node, peerInfo: PeerInfo): Peer {.gcsafe.} =
|
||||
|
@ -572,6 +566,11 @@ proc handleIncomingStream(network: Eth2Node,
|
|||
try:
|
||||
let peer = peerFromStream(network, conn)
|
||||
|
||||
# TODO peer connection setup is broken, update info in some better place
|
||||
# whenever race is fix:
|
||||
# https://github.com/status-im/nim-beacon-chain/issues/1157
|
||||
peer.info = conn.peerInfo
|
||||
|
||||
template returnInvalidRequest(msg: ErrorMsg) =
|
||||
await sendErrorResponse(peer, conn, noSnappy, InvalidRequest, msg)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue