Add Node to Version Stat
add_node_to_version_stat
The add_node_to_version_stat method adds a node’s name, IP address, and PeerID to a local database to track which version of KDF it is running. The name parameter is an arbitrary identifying string, such as seed_alpha or dragonhound_DEV. The address parameter is the node’s IP address or domain name. The Peer ID can be found in the KDF log file after a connection has been initiated, and looks like the below:
07 09:33:58, atomicdex_behaviour:610] INFO Local peer id: PeerId("12D3KooWReXsTVCKGAna1tzrD1jaUttTSs17ULFuvvzoGD9bqmmA")
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | ✓ | The name assigned to the node |
| address | string | ✓ | The IP address of the node |
| peer_id | string | ✓ | The node's unique Peer ID |
Response Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| result | string | ✓ | The outcome of the request. |
📌 Examples
POST Add Node to Version Stat
add_node_to_version_stat {
"mmrpc": "2.0",
"method": "add_node_to_version_stat",
"userpass": "RPC_UserP@SSW0RD",
"params": {
"name": "seed1",
"address": "168.119.236.241",
"peer_id": "12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P"
}
} curl --url "http://127.0.0.1:7783" --data '{
"mmrpc": "2.0",
"method": "add_node_to_version_stat",
"userpass": "RPC_UserP@SSW0RD",
"params": {
"name": "seed1",
"address": "168.119.236.241",
"peer_id": "12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P"
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"mmrpc": "2.0",
"method": "add_node_to_version_stat",
"userpass": "RPC_UserP@SSW0RD",
"params": {
"name": "seed1",
"address": "168.119.236.241",
"peer_id": "12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P"
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"mmrpc": "2.0",
"method": "add_node_to_version_stat",
"userpass": "RPC_UserP@SSW0RD",
"params": {
"name": "seed1",
"address": "168.119.236.241",
"peer_id": "12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P"
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"mmrpc": "2.0",
"method": "add_node_to_version_stat",
"userpass": "RPC_UserP@SSW0RD",
"params": {
"name": "seed1",
"address": "168.119.236.241",
"peer_id": "12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P"
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"mmrpc":"2.0","method":"add_node_to_version_stat","userpass":"RPC_UserP@SSW0RD","params":{"name":"seed1","address":"168.119.236.241","peer_id":"12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P"}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"mmrpc": "2.0",
"method": "add_node_to_version_stat",
"userpass": "RPC_UserP@SSW0RD",
"params": {
"name": "seed1",
"address": "168.119.236.241",
"peer_id": "12D3KooWEsuiKcQaBaKEzuMtT6uFjs89P1E8MK3wGRZbeuCbCw6P"
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Add Node to Version Stat Response
Response (success)
{
"mmrpc": "2.0",
"result": "success",
"id": null
} Error Types
| Parameter | Type | Required | Description |
|---|---|---|---|
| DatabaseError | string | – | Database constraint error occurred. |
| PeerIdParseError | string | – | The provided peer ID format is invalid. |
Show Error Responses
⚠️ Error Responses
DatabaseError (Unique Constraint - Peer ID)
{
"mmrpc": "2.0",
"error": "Database error: UNIQUE constraint failed: nodes.peer_id",
"error_path": "lp_stats",
"error_trace": "lp_stats:124]",
"error_type": "DatabaseError",
"error_data": "UNIQUE constraint failed: nodes.peer_id",
"id": null
}DatabaseError (Unique Constraint - Name)
{
"mmrpc": "2.0",
"error": "Database error: UNIQUE constraint failed: nodes.name",
"error_path": "lp_stats",
"error_trace": "lp_stats:124]",
"error_type": "DatabaseError",
"error_data": "UNIQUE constraint failed: nodes.name",
"id": null
}PeerIdParseError
{
"mmrpc": "2.0",
"error": "Error on parse peer id 12D3RsaaWRmXsJsCKGAD5FJSsd7CSbbdrsd: decoding multihash failed",
"error_path": "lp_stats",
"error_trace": "lp_stats:121]",
"error_type": "PeerIdParseError",
"error_data": [
"12D3RsaaWRmXsJsCKGAD5FJSsd7CSbbdrsd",
"decoding multihash failed"
],
"id": null
}