[][src]Crate exonum_explorer_service

Exonum explorer service.

The explorer service does not define transactions, but it has several REST / WebSocket endpoints allowing to retrieve information from the blockchain in a structured way. Usually, the explorer service should be instantiated at the blockchain start with the default identifiers. There may be no more than one explorer service on a blockchain; an attempt to create a second service instance will lead to an error in the service constructor.

The API types necessary to interact with the service HTTP API are defined in a separate crate, exonum-explorer. The base explorer provides Rust language APIs for retrieving info from the blockchain, while this crate translates these APIs into REST and WebSocket endpoints and packages this logic as an Exonum service. Thus, this crate is useful if you want to provide the way for external apps to query the blockchain info.

HTTP API

REST API of the service is documented in the api module, and its WebSocket API in the api::websocket module.

Examples

Use with Testkit

use exonum_explorer::api::BlocksRange;
use exonum_explorer_service::ExplorerFactory;
use exonum_testkit::{ApiKind, TestKit, TestKitBuilder};

let mut testkit: TestKit = TestKitBuilder::validator()
    .with_default_rust_service(ExplorerFactory)
    // Add other services here
    .build();
// The explorer endpoints can be accessed via `api()`:
let api = testkit.api();
let BlocksRange { blocks, range } = api
    .public(ApiKind::Explorer)
    .get("v1/blocks?count=10")
    .unwrap();

Modules

api

HTTP API for the explorer service. All APIs are accessible from the public HTTP server of the node.

Structs

ExplorerFactory

Explorer service factory.

ExplorerService

Explorer service.

Enums

Error

Errors that can occur during explorer service operation.