Skip to main content

Manual Peering API methods

The manual peering APIs allow managing the list of known peers of the node.

HTTP APIs:

Client lib APIs:

POST /manualpeering/peers

Add peers to the list of known peers of the node.

Request Body

[
{
"publicKey": "CHfU1NUf6ZvUKDQHTG2df53GR7CvuMFtyt7YymJ6DwS3",
"address": "127.0.0.1:14666"
}
]

Description

FieldDescription
publicKeyPublic key of the peer.
addressIP address of the peer's node and its gossip port.

Response

HTTP status code: 204 No Content

Examples

cURL

curl --location --request POST 'http://localhost:8080/manualpeering/peers' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"publicKey": "CHfU1NUf6ZvUKDQHTG2df53GR7CvuMFtyt7YymJ6DwS3",
"address": "172.19.0.3:14666"
}
]'

Client library

AddManualPeers

import "github.com/iotaledger/goshimmer/packages/manualpeering"

peersToAdd := []*manualpeering.KnownPeerToAdd{{PublicKey: publicKey, Address: address}}
err := goshimAPI.AddManualPeers(peersToAdd)
if err != nil {
// return error
}

GET /manualpeering/peers

Get the list of all known peers of the node.

Request Body

{
"onlyConnected": true
}

Description

FieldDescription
onlyConnectedOptional, if set to true only peers with established connection will be returned.

Response

HTTP status code: 200 OK

[
{
"publicKey": "CHfU1NUf6ZvUKDQHTG2df53GR7CvuMFtyt7YymJ6DwS3",
"address": "127.0.0.1:14666",
"connectionDirection": "inbound",
"connectionStatus": "connected"
}
]

Description

FieldDescription
publicKeyThe public key of the peer node.
addressIP address of the peer's node and its gossip port.
connectionDirectionEnum, possible values: "inbound", "outbound". Inbound means that the local node accepts the connection. On the other side, the other peer node dials, and it will have "outbound" connectionDirection.
connectionStatusEnum, possible values: "disconnected", "connected". Whether the actual TCP connection has been established between peers.

Examples

cURL

curl --location --request GET 'http://localhost:8080/manualpeering/peers' \
--header 'Content-Type: application/json' \
--data-raw '{
"onlyConnected": true
}'

Client library

GetManualPeers

import "github.com/iotaledger/goshimmer/packages/manualpeering"

peers, err := goshimAPI.GetManualPeers(manualpeering.WithOnlyConnectedPeers())
if err != nil {
// return error
}
fmt.Println(peers)

DELETE /manualpeering/peers

Remove peers from the list of known peers of the node.

Request Body

[
{
"publicKey": "CHfU1NUf6ZvUKDQHTG2df53GR7CvuMFtyt7YymJ6DwS3"
}
]

Description

FieldDescription
publicKeyPublic key of the peer to remove from the list.

Response

HTTP status code: 204 No Content

Examples

cURL

curl --location --request DELETE 'http://localhost:8080/manualpeering/peers' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"publicKey": "8qN1yD95fhbfDZtKX49RYFEXqej5fvsXJ2NPmF1LCqbd"
}
]'

Client library

RemoveManualPeers

import "github.com/iotaledger/hive.go/crypto/ed25519"
import "github.com/iotaledger/goshimmer/packages/manualpeering"

publicKeysToRemove := []ed25519.PublicKey{publicKey1, publicKey2}
err := goshimAPI.RemoveManualPeers(publicKeysToRemove)
if err != nil {
// return error
}