tenderdash_abci/
lib.rs

1//! Tenderdash ABCI Application library.
2//!
3//! ABCI Application is responsible for storage and implementation of
4//! application state.
5//!
6//! Use [[start_server]] to create a new server that will accept connections
7//! from Tenderdash.
8//!
9//! Run [Server::handle_connection()] in a loop to handle incoming server
10//! connections.
11//!
12//! Implement the [application::Application] trait with custom logic for
13//! blockchain processing. Expect messages defined in [proto::abci] crate.
14
15mod application;
16#[cfg(feature = "server")]
17mod server;
18
19use std::io;
20
21pub use application::{Application, RequestDispatcher, check_version};
22#[allow(deprecated)]
23#[cfg(feature = "server")]
24pub use server::{CancellationToken, Server, ServerBuilder, ServerRuntime, start_server};
25pub use tenderdash_proto as proto;
26use tenderdash_proto::prost::{DecodeError, EncodeError};
27
28#[cfg(feature = "crypto")]
29mod merkle;
30#[cfg(feature = "crypto")]
31pub mod signatures;
32
33#[cfg(feature = "tracing-span")]
34/// Create tracing::Span for better logging
35pub mod tracing_span;
36
37/// Errors that may happen during protobuf communication
38#[derive(Debug, thiserror::Error)]
39pub enum Error {
40    #[error("configuration error: {0}")]
41    Configuration(String),
42    #[error("connection error")]
43    Connection(#[from] io::Error),
44    #[error("cannot decode protobuf message")]
45    Decode(DecodeError),
46    #[error("cannot encode protobuf message")]
47    Encode(EncodeError),
48    #[error("cannot create canonical message: {0}")]
49    Canonical(String),
50    #[error("server terminated")]
51    Cancelled(),
52    #[error("async runtime error")]
53    Async(String),
54}
55
56// manually implemented due to no_std compatibility
57impl From<EncodeError> for Error {
58    fn from(error: EncodeError) -> Error {
59        Error::Encode(error)
60    }
61}
62
63// manually implemented due to no_std compatibility
64impl From<DecodeError> for Error {
65    fn from(error: DecodeError) -> Error {
66        Error::Decode(error)
67    }
68}