[][src]Crate exonum_system_api

System API of an Exonum node, packaged as a node plugin.

HTTP API

REST API of the service is documented in the corresponding modules:

Examples

Use with the real node builder:

use exonum::{
    blockchain::config::GenesisConfig,
    keys::Keys,
    merkledb::TemporaryDB,
};
use exonum_node::{NodeBuilder, NodeConfig};
use exonum_system_api::SystemApiPlugin;

let node_config: NodeConfig = // ...
let node_keys = Keys::random();
let genesis_config: GenesisConfig = // ...
let db = TemporaryDB::new();
let node = NodeBuilder::new(db, node_config, node_keys)
    .with_genesis_config(genesis_config)
    .with_plugin(SystemApiPlugin)
    // Add runtimes etc...
    .build();
node.run().await?;

Use with the testkit:

use exonum_system_api::{private::{ConsensusStatus, 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?;
assert_eq!(info.consensus_status, ConsensusStatus::Enabled);
Ok(())

Note that the testkit does not emulate the functionality of the node completely; it does not update the SharedNodeState.

Modules

private

Private part of the node REST API.

Structs

SystemApiPlugin

Plugin responsible for adding system API to the Exonum node.