[−][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
Property | Value |
---|---|
Path | /api/system/v1/info |
Method | GET |
Query type | - |
Return type | NodeInfo |
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
Property | Value |
---|---|
Path | /api/system/v1/stats |
Method | GET |
Query type | - |
Return type | NodeStats |
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
Property | Value |
---|---|
Path | /api/system/v1/peers |
Method | POST |
Query type | ConnectInfo |
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
Property | Value |
---|---|
Path | /api/system/v1/consensus_status |
Method | POST |
Query type | ConsensusEnabledQuery |
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
Property | Value |
---|---|
Path | /api/system/v1/shutdown |
Method | POST |
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. |