[−][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
- Add peer
- Get node info
- Check if consensus is enabled
- Change consensus status
- Node shutdown
List Peers
Property | Value |
---|---|
Path | /api/system/v1/peers |
Method | GET |
Query type | - |
Return type | PeersInfo |
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
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.
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
Property | Value |
---|---|
Path | /api/system/v1/network |
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/network")?;
Check if Consensus is Enabled
Property | Value |
---|---|
Path | /api/system/v1/consensus_enabled |
Method | GET |
Query type | - |
Return type | bool |
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
Property | Value |
---|---|
Path | /api/system/v1/consensus_enabled |
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 { enabled }; api.private(ApiKind::System) .query(&query) .post("v1/consensus_enabled")?;
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")?;
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. |