pub trait ServerModule: Debug + Sized {
    type Common: ModuleCommon;
    type Init: ServerModuleInit;

    // Required methods
    fn consensus_proposal<'a, 'life0, 'life1, 'async_trait>(
        &'a self,
        dbtx: &'life0 mut DatabaseTransaction<'life1>
    ) -> Pin<Box<dyn Future<Output = Vec<<Self::Common as ModuleCommon>::ConsensusItem>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn process_consensus_item<'a, 'b, 'life0, 'async_trait>(
        &'a self,
        dbtx: &'life0 mut DatabaseTransaction<'b>,
        consensus_item: <Self::Common as ModuleCommon>::ConsensusItem,
        peer_id: PeerId
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'b: 'async_trait,
             'life0: 'async_trait;
    fn process_input<'a, 'b, 'c, 'life0, 'async_trait>(
        &'a self,
        dbtx: &'life0 mut DatabaseTransaction<'c>,
        input: &'b <Self::Common as ModuleCommon>::Input
    ) -> Pin<Box<dyn Future<Output = Result<InputMeta, <Self::Common as ModuleCommon>::InputError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'b: 'async_trait,
             'c: 'async_trait,
             'life0: 'async_trait;
    fn process_output<'a, 'b, 'life0, 'async_trait>(
        &'a self,
        dbtx: &'life0 mut DatabaseTransaction<'b>,
        output: &'a <Self::Common as ModuleCommon>::Output,
        out_point: OutPoint
    ) -> Pin<Box<dyn Future<Output = Result<TransactionItemAmount, <Self::Common as ModuleCommon>::OutputError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'b: 'async_trait,
             'life0: 'async_trait;
    fn output_status<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        dbtx: &'life1 mut DatabaseTransaction<'life2>,
        out_point: OutPoint
    ) -> Pin<Box<dyn Future<Output = Option<<Self::Common as ModuleCommon>::OutputOutcome>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn audit<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        dbtx: &'life1 mut DatabaseTransaction<'life2>,
        audit: &'life3 mut Audit,
        module_instance_id: ModuleInstanceId
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn api_endpoints(&self) -> Vec<ApiEndpoint<Self>>;

    // Provided methods
    fn module_kind() -> ModuleKind { ... }
    fn decoder() -> Decoder { ... }
}

Required Associated Types§

Required Methods§

source

fn consensus_proposal<'a, 'life0, 'life1, 'async_trait>( &'a self, dbtx: &'life0 mut DatabaseTransaction<'life1> ) -> Pin<Box<dyn Future<Output = Vec<<Self::Common as ModuleCommon>::ConsensusItem>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

This module’s contribution to the next consensus proposal

source

fn process_consensus_item<'a, 'b, 'life0, 'async_trait>( &'a self, dbtx: &'life0 mut DatabaseTransaction<'b>, consensus_item: <Self::Common as ModuleCommon>::ConsensusItem, peer_id: PeerId ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'b: 'async_trait, 'life0: 'async_trait,

This function is called once for every consensus item. The function returns an error if and only if the consensus item does not change our state and therefore may be safely discarded by the atomic broadcast.

source

fn process_input<'a, 'b, 'c, 'life0, 'async_trait>( &'a self, dbtx: &'life0 mut DatabaseTransaction<'c>, input: &'b <Self::Common as ModuleCommon>::Input ) -> Pin<Box<dyn Future<Output = Result<InputMeta, <Self::Common as ModuleCommon>::InputError>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'b: 'async_trait, 'c: 'async_trait, 'life0: 'async_trait,

Try to spend a transaction input. On success all necessary updates will be part of the database transaction. On failure (e.g. double spend) the database transaction is rolled back and the operation will take no effect.

source

fn process_output<'a, 'b, 'life0, 'async_trait>( &'a self, dbtx: &'life0 mut DatabaseTransaction<'b>, output: &'a <Self::Common as ModuleCommon>::Output, out_point: OutPoint ) -> Pin<Box<dyn Future<Output = Result<TransactionItemAmount, <Self::Common as ModuleCommon>::OutputError>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'b: 'async_trait, 'life0: 'async_trait,

Try to create an output (e.g. issue notes, peg-out BTC, …). On success all necessary updates to the database will be part of the database transaction. On failure (e.g. double spend) the database transaction is rolled back and the operation will take no effect.

The supplied out_point identifies the operation (e.g. a peg-out or note issuance) and can be used to retrieve its outcome later using output_status.

source

fn output_status<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dbtx: &'life1 mut DatabaseTransaction<'life2>, out_point: OutPoint ) -> Pin<Box<dyn Future<Output = Option<<Self::Common as ModuleCommon>::OutputOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieve the current status of the output. Depending on the module this might contain data needed by the client to access funds or give an estimate of when funds will be available. Returns None if the output is unknown, NOT if it is just not ready yet.

source

fn audit<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, dbtx: &'life1 mut DatabaseTransaction<'life2>, audit: &'life3 mut Audit, module_instance_id: ModuleInstanceId ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Queries the database and returns all assets and liabilities of the module.

Summing over all modules, if liabilities > assets then an error has occurred in the database and consensus should halt.

source

fn api_endpoints(&self) -> Vec<ApiEndpoint<Self>>

Returns a list of custom API endpoints defined by the module. These are made available both to users as well as to other modules. They thus should be deterministic, only dependant on their input and the current epoch.

Provided Methods§

source

fn module_kind() -> ModuleKind

source

fn decoder() -> Decoder

Returns a decoder for the following associated types of this module:

  • Input
  • Output
  • OutputOutcome
  • ConsensusItem

Object Safety§

This trait is not object safe.

Implementors§