Networking

From Nxtwiki
Jump to: navigation, search

Add Peer

Add a peer to the list of known peers and attempt to connect to it. Password protected like the Debug Operations. POST only.

Request:

  • requestType is addPeer
  • peer is the IP address or domain name of the peer (plus optional port)

Response: refer to Get Peer

  • isNewlyAdded is true if the peer was not already known, omitted otherwise

Add Peer Example

http://localhost:7876/nxt?
  requestType=addPeer&
  peer=nxt9.webice.ru
{
 "hallmark": "4a8fd0f2af5f511e041ad7bee1625ae3a711ddcc056c60cf7ab3523e2c99092f0e006e...",
 "downloadedVolume": 155414,
 "address": "23.95.51.154",
 "weight": 19829,
 "uploadedVolume": 63532,
 "requestProcessingTime": 478,
 "version": "1.4.8",
 "platform": "webice.ru",
 "lastUpdated": 37014605,
 "blacklisted": false,
 "announcedAddress": "nxt9.webice.ru",
 "application": "NRS",
 "state": 1,
 "shareAddress": true
}


Blacklist API Proxy Peer

Blacklist a remote node from the UI, so it won't be used when in roaming and light client modes. POST only.

Request:

  • requestType is blacklistAPIProxyPeer
  • peer is the IP address or domain name of the peer (plus optional port)
  • adminPassword is a string with the admin password (optional)

Response:

  • done (B) is true if the peer is blacklisted
  • requestProcessingTime (N) is the API request processing time (in millisec)

Blacklist API Proxy Peer Example

http://localhost:7876/nxt?
  requestType=blacklistAPIProxyPeer&
  peer=52.0.72.67
{
 "requestProcessingTime": 24,
 "done": true
}


Blacklist Peer

Blacklist a peer for the default blacklisting period. Password protected like the Debug Operations. POST only.

Request:

  • requestType is blacklistPeer
  • peer is the IP address or domain name of the peer (plus optional port)

Response:

  • done (B) is true if the peer is blacklisted
  • requestProcessingTime (N) is the API request processing time (in millisec)

Blacklist Peer Example

http://localhost:7876/nxt?
  requestType=blacklistPeer&
  peer=nxt9.webice.ru
{
 "requestProcessingTime": 0,
 "done": true
}


Get Inbound Peers

Get all peers that have sent a request to this peer in the last 30 minutes.

Request:

  • requestType is getInboundPeers
  • includePeerInfo is true to include peer information, otherwise include only the address (optional)

Response:

  • peers (A) is an array of peer addresses or peer objects (refer to Get Peer for details) depending on includePeerInfo
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Inbound Peers Example

http://localhost:7876/nxt?
  requestType=getInboundPeers
{
 "peers": [],
 "requestProcessingTime": 1
}


Get My Info

Get hostname and address of the requesting node.

Request:

  • requestType is getMyInfo

Response:

  • host (S) is the node hostname
  • address (S) is the node address
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get My Info Example

http://localhost:7876/nxt?
  requestType=getMyInfo
{
 "address": "127.0.0.1",
 "host": "127.0.0.1",
 "requestProcessingTime": 1
}


Get Peer

Get information about a given peer.

Request:

  • requestType is getPeer
  • peer is the IP address or domain name of the peer (plus optional port)

Response:

  • hallmark (S) is the hex string of the peer's hallmark, if it is defined
  • downloadedVolume (N) is the number of bytes downloaded by the peer
  • address (S) the IP address or DNS name of the peer
  • weight (N) is the peer's weight value
  • uploadedVolume (N) is the number of bytes uploaded by the peer
  • version (S) is the version of the software running on the peer
  • platform (S) is a string representing the peer's platform
  • lastUpdated (N) is the timestamp (in seconds since the genesis block) of the last peer status update
  • blacklisted (B) is true if the peer is blacklisted
  • services (A) is an array of strings with the services the node provides
  • blacklistingCause (S) is the cause of blacklisting (if blacklisted is true)
  • announcedAddress (S) is the name that the peer announced to the network (could be a DNS name, IP address, or any other string)
  • application (S) is the name of the software application, typically NRS
  • state (N) defines the state of the peer: 0 for NON_CONNECTED, 1 for CONNECTED, or 2 for DISCONNECTED
  • shareAddress (B) is true if the address is allowed to be shared with other peers
  • inbound (B) is true if the peer has made a request to this node
  • inboundWebSocket (B) is true if an inbound websocket has been established from this node
  • outboundWebSocket (B) is true if an outbound websocket has been established to this node
  • lastConnectAttempt (B) is the timestamp (in seconds since the genesis block) of the last connection attempt to the peer
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Peer Example

http://localhost:7876/nxt?
  requestType=getPeer&
  peer=nxtx.ru
{
 "hallmark": "5f107c33097fc8241f55b9eb23615fe80ed3f87c87dc8c23ed6a08ab9273417a07006...",
 "downloadedVolume": 352,
 "address": "188.226.174.169",
 "inbound": false,
 "weight": 53,
 "uploadedVolume": 2165,
 "requestProcessingTime": 30,
 "version": "1.5.11",
 "platform": "VPS",
 "inboundWebSocket": false,
 "lastUpdated": 48540348,
 "blacklisted": false,
 "announcedAddress": "nxtx.ru",
 "application": "NRS",
 "port": 7874,
 "outboundWebSocket": true,
 "lastConnectAttempt": 48540348,
 "state": 1,
 "shareAddress": true
}


Get Peers

Get a list of peer IP addresses.

Request:

  • requestType is getPeers
  • active is true for active (not NON_CONNECTED) peers only (optional, if true overrides state)
  • state is the state of the peers, one of NON_CONNECTED, CONNECTED, or DISCONNECTED (optional)
  • includePeerInfo is true to include peer detail as in Get Peer
  • service to filter on a specific service

Note: If neither active nor state is specified, all known peers are retrieved.

Response:

  • peers (A) is an array of peer addresses
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Peers Example

http://localhost:7876/nxt?
  requestType=getPeers&
  state=DISCONNECTED
{
 "peers": [
  "198.50.146.93",
  "213.46.57.77"
 ],
 "requestProcessingTime": 1
}


Set API Proxy Peer

Set the remote node to use when in roaming and light client modes. POST only.

Request:

  • requestType is setAPIProxyPeer
  • peer is the IP address or domain name of the peer (plus optional port)
  • adminPassword is a string with the admin password (optional)

Response:

  • downloadedVolume (N) is the number of bytes downloaded by the peer
  • address (S) the IP address or DNS name of the peer
  • weight (N) is the peer's weight value
  • uploadedVolume (N) is the number of bytes uploaded by the peer
  • version (S) is the version of the software running on the peer
  • platform (S) is a string representing the peer's platform
  • blockchainState (S) is a string describing the state of the blockchain in the peer
  • lastUpdated (N) is the timestamp (in seconds since the genesis block) of the last peer status update
  • blacklisted (B) is true if the peer is blacklisted
  • services (A) is an array of strings with the services the node provides
  • apiPort (N) is the API access port of the peer
  • apiSSLPort (N) is the SSL API access port of the peer
  • blacklistingCause (S) is the cause of blacklisting (if blacklisted is true)
  • announcedAddress (S) is the name that the peer announced to the network (could be a DNS name, IP address, or any other string)
  • application (S) is the name of the software application, typically NRS
  • state (N) defines the state of the peer: 0 for NON_CONNECTED, 1 for CONNECTED, or 2 for DISCONNECTED
  • shareAddress (B) is true if the address is allowed to be shared with other peers
  • inbound (B) is true if the peer has made a request to this node
  • inboundWebSocket (B) is true if an inbound websocket has been established from this node
  • outboundWebSocket (B) is true if an outbound websocket has been established to this node
  • lastConnectAttempt (B) is the timestamp (in seconds since the genesis block) of the last connection attempt to the peer
  • requestProcessingTime (N) is the API request processing time (in millisec)

Set API Proxy Peer Example

http://localhost:7876/nxt?
  requestType=setAPIProxyPeer&
  peer=163.172.154.74
{
 "downloadedVolume":6176,
 "address":"104.223.53.14",
 "inbound":false,
 "blockchainState":"UP_TO_DATE",
 "weight":0,
 "uploadedVolume":323,
 "services":[
  "HALLMARK","PRUNABLE","API","API_SSL","CORS"
  ],
 "requestProcessingTime":77,
 "version":"1.11.5",
 "platform":"NXT-TGFQ-U33C-C37U-CMKWF",
 "inboundWebSocket":false,
 "apiSSLPort":7878,
 "lastUpdated":112610887,
 "blacklisted":false,
 "announcedAddress":"104.223.53.14",
 "apiPort":7876,
 "application":"NRS",
 "port":7874,
 "outboundWebSocket":true,
 "lastConnectAttempt":112610887,
 "state":1,
 "shareAddress":true
}