Skip to content

chore: add /api/peers/get endpoint and update peer info #21

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

Merged
merged 2 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions specification/nodes/GetPeerInfo/GetPeerInfoParams.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- name: ip
in: query
description: The peer's IPv4 address.
required: true
schema:
type: string
format: ipv4
example: 194.32.79.175
- name: port
in: query
description: The peer's port number.
required: true
schema:
type: integer
format: int32
example: 36666
11 changes: 11 additions & 0 deletions specification/nodes/GetPeerInfo/GetPeerInfoResponseDto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
required:
- peer
- success
- nodeTimestamp
properties:
peer:
$ref: "../PeerDto.yaml"
success:
type: boolean
nodeTimestamp:
type: number
2 changes: 1 addition & 1 deletion specification/nodes/GetPeers/GetPeersResponseDto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ properties:
peers:
type: array
items:
$ref: "./PeerDto.yaml"
$ref: "../PeerDto.yaml"
success:
type: boolean
nodeTimestamp:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ required:
- clock
- updated
- nonce
- isBroadcastingViaSocket
- syncProtocol
properties:
ip:
type: string
Expand Down Expand Up @@ -40,6 +42,13 @@ properties:
nonce:
type: string
description: Unique Identifier for the peer. Random string.
isBroadcastingViaSocket:
type: boolean
description: Indicates whether the node can send transactions to the peer over WebSocket.
syncProtocol:
type: string
enum: ["http", "ws"]
description: "Indicates the protocol used to subscribe to the peer: 'http' if using HTTP only, or 'ws' if using WebSocket, which also allows receiving transactions via both WebSocket and HTTP."
example:
ip: 194.32.79.175
port: 36666
Expand All @@ -51,3 +60,5 @@ example:
clock: null
updated: 1562424199553
nonce: jxXV6g0sHJhmDubq
isBroadcastingViaSocket: false
syncProtocol: ws
17 changes: 17 additions & 0 deletions specification/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ components:
# Nodes and Blockchain
GetPeersResponseDto:
$ref: "nodes/GetPeers/GetPeersResponseDto.yaml"
GetPeerInfoResponseDto:
$ref: "nodes/GetPeerInfo/GetPeerInfoResponseDto.yaml"
GetLoadingStatusResponseDto:
$ref: "nodes/GetLoadingStatus/GetLoadingStatusResponseDto.yaml"
GetSyncStatusResponseDto:
Expand Down Expand Up @@ -507,6 +509,21 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/GetPeersResponseDto"
"/peers/get":
get:
tags:
- Nodes and Blockchain
operationId: getPeer
description: Finds and returns the known peer of the node.
parameters:
$ref: "nodes/GetPeerInfo/GetPeerInfoParams.yaml"
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: "#/components/schemas/GetPeerInfoResponseDto"
"/loader/status":
get:
tags:
Expand Down