Trait exonum::blockchain::Service
[−]
[src]
pub trait Service: Send + Sync + 'static { fn service_id(&self) -> u16; fn service_name(&self) -> &'static str; fn tx_from_raw(
&self,
raw: RawTransaction
) -> Result<Box<Transaction>, MessageError>; fn state_hash(&self, _: &Snapshot) -> Vec<Hash> { ... } fn initialize(&self, fork: &mut Fork) -> Value { ... } fn handle_commit(&self, context: &mut ServiceContext) { ... } fn public_api_handler(&self, context: &ApiContext) -> Option<Box<Handler>> { ... } fn private_api_handler(&self, context: &ApiContext) -> Option<Box<Handler>> { ... } }
A trait that describes a business-logic of the concrete service.
Required Methods
fn service_id(&self) -> u16
Unique service identification for database schema and service messages.
fn service_name(&self) -> &'static str
Unique human readable service name.
fn tx_from_raw(
&self,
raw: RawTransaction
) -> Result<Box<Transaction>, MessageError>
&self,
raw: RawTransaction
) -> Result<Box<Transaction>, MessageError>
Tries to create Transaction
object from the given raw message.
Provided Methods
fn state_hash(&self, _: &Snapshot) -> Vec<Hash>
Returns a list of root hashes of tables that determine the current state
of the service database. These hashes are collected from all services in a common
MerklePatriciaTable
that named state_hash_aggregator
.
See also service_table_unique_key
.
fn initialize(&self, fork: &mut Fork) -> Value
By this method you can initialize information schema of service and generates initial service configuration. This method is called on genesis block creation event.
fn handle_commit(&self, context: &mut ServiceContext)
Handles commit event. This handler is invoked for each service after commit of the block. For example service can create some transaction if the specific condition occurred.
Try not to perform long operations here.
fn public_api_handler(&self, context: &ApiContext) -> Option<Box<Handler>>
Returns api handler for public users.
fn private_api_handler(&self, context: &ApiContext) -> Option<Box<Handler>>
Returns api handler for maintainers.