[][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

List Peers

PropertyValue
Path/api/system/v1/peers
MethodGET
Query type-
Return typePeersInfo

Returns the list of incoming and outgoing connections for current node.

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

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

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.

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")?;

Get Node Info

PropertyValue
Path/api/system/v1/network
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/network")?;

Check if Consensus is Enabled

PropertyValue
Path/api/system/v1/consensus_enabled
MethodGET
Query type-
Return typebool

Returns true if consensus is enabled on the node, and false otherwise.

Note the difference between consensus_enabled and public healthcheck endpoint:

This endpoint only reports the setting value (should the node participate in consensus or not), while healthcheck provides information about consensus status (since even with consensus setting turned on, node may not participate in consensus due to lack of peers).

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

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

Change Consensus Status

PropertyValue
Path/api/system/v1/consensus_enabled
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 { enabled };
api.private(ApiKind::System)
    .query(&query)
    .post("v1/consensus_enabled")?;

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")?;

Structs

ConsensusEnabledQuery

Query for setting consensus enabled or disabled.

NodeInfo

Short information about the current node.

OutgoingConnection

Information about the outgoing connection.

PeersInfo

Information about connections of the node.

ServiceInfo

Short information about the service.