[][src]Module exonum_system_api::private

Private part of the node REST API.

Private API includes requests that are available only to the blockchain administrators, e.g. shutting down the node.

Table of Contents

Get Node Info

PropertyValue
Path/api/system/v1/info
MethodGET
Query type-
Return typeNodeInfo

Obtains information about node.

use exonum_system_api::{private::NodeInfo, SystemApiPlugin};
use exonum_testkit::{ApiKind, TestKitBuilder};

let mut testkit = TestKitBuilder::validator()
    .with_plugin(SystemApiPlugin)
    .build();
let api = testkit.api();
let info: NodeInfo = api.private(ApiKind::System).get("v1/info").await?;

Get Node Statistics

PropertyValue
Path/api/system/v1/stats
MethodGET
Query type-
Return typeNodeStats

Returns the statistics of the current node.

use exonum_system_api::{private::NodeStats, SystemApiPlugin};
use exonum_testkit::{ApiKind, TestKitBuilder};

let mut testkit = TestKitBuilder::validator()
    .with_plugin(SystemApiPlugin)
    .build();
let api = testkit.api();
let info: NodeStats = api.private(ApiKind::System).get("v1/stats").await?;

Add Peer

PropertyValue
Path/api/system/v1/peers
MethodPOST
Query typeConnectInfo
Return type-

Adds a peer to the Exonum node. Node will attempt to connect to this peer. After adding a new peer the node config file will be rewritten.

use exonum_node::ConnectInfo;
use exonum_system_api::SystemApiPlugin;
use exonum_testkit::{ApiKind, TestKitBuilder};

// Obtaining address and public key of target node skipped...
let connect_info = ConnectInfo {
    address,
    public_key,
};

let mut testkit = TestKitBuilder::validator()
    .with_plugin(SystemApiPlugin)
    .build();
let api = testkit.api();
api.private(ApiKind::System)
    .query(&connect_info)
    .post("v1/peers")
    .await?;

Change Consensus Status

PropertyValue
Path/api/system/v1/consensus_status
MethodPOST
Query typeConsensusEnabledQuery
Return type-

Enables or disables consensus on the node.

use exonum_system_api::{private::ConsensusEnabledQuery, SystemApiPlugin};
use exonum_testkit::{ApiKind, TestKitBuilder};

let mut testkit = TestKitBuilder::validator()
    .with_plugin(SystemApiPlugin)
    .build();
let api = testkit.api();
let enabled = true;
let query = ConsensusEnabledQuery::new(enabled);
api.private(ApiKind::System)
    .query(&query)
    .post("v1/consensus_status")
    .await?;

Node Shutdown

PropertyValue
Path/api/system/v1/shutdown
MethodPOST
Query type-
Return type-

Shuts down the node.

use exonum_system_api::SystemApiPlugin;
use exonum_testkit::{ApiKind, TestKitBuilder};

let mut testkit = TestKitBuilder::validator()
    .with_plugin(SystemApiPlugin)
    .build();
let api = testkit.api();
api.private(ApiKind::System)
    .post::<()>("v1/shutdown")
    .await?;

Structs

ConnectedPeerInfo

Info about connected peer.

ConsensusEnabledQuery

Query for setting consensus enabled or disabled.

NodeInfo

Short information about the current node.

NodeStats

Information about the current state of the node.

Enums

ConnectDirection

Type of the network connection.

ConsensusStatus

Consensus status of the current node.