pub trait IServerModule: Debug {
// Required methods
fn as_any(&self) -> &dyn Any;
fn decoder(&self) -> Decoder;
fn module_kind(&self) -> ModuleKind;
fn consensus_proposal<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'life2>,
module_instance_id: ModuleInstanceId,
) -> Pin<Box<dyn Future<Output = Vec<DynModuleConsensusItem>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn process_consensus_item<'a, 'b, 'life0, 'life1, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'a>,
consensus_item: &'b DynModuleConsensusItem,
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,
'life1: 'async_trait;
fn verify_input(&self, input: &DynInput) -> Result<(), DynInputError>;
fn process_input<'a, 'b, 'c, 'life0, 'async_trait>(
&'a self,
dbtx: &'life0 mut DatabaseTransaction<'c>,
input: &'b DynInput,
) -> Pin<Box<dyn Future<Output = Result<InputMeta, DynInputError>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'b: 'async_trait,
'c: 'async_trait,
'life0: 'async_trait;
fn process_output<'a, 'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'a>,
output: &'life2 DynOutput,
out_point: OutPoint,
) -> Pin<Box<dyn Future<Output = Result<TransactionItemAmount, DynOutputError>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn output_status<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'life2>,
out_point: OutPoint,
module_instance_id: ModuleInstanceId,
) -> Pin<Box<dyn Future<Output = Option<DynOutputOutcome>> + 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<DynServerModule>>;
}
Expand description
Backend side module interface
Server side Fedimint module needs to implement this trait.
Required Methods§
fn as_any(&self) -> &dyn Any
fn module_kind(&self) -> ModuleKind
Sourcefn consensus_proposal<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'life2>,
module_instance_id: ModuleInstanceId,
) -> Pin<Box<dyn Future<Output = Vec<DynModuleConsensusItem>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn consensus_proposal<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'life2>,
module_instance_id: ModuleInstanceId,
) -> Pin<Box<dyn Future<Output = Vec<DynModuleConsensusItem>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
This module’s contribution to the next consensus proposal
Sourcefn process_consensus_item<'a, 'b, 'life0, 'life1, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'a>,
consensus_item: &'b DynModuleConsensusItem,
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,
'life1: 'async_trait,
fn process_consensus_item<'a, 'b, 'life0, 'life1, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'a>,
consensus_item: &'b DynModuleConsensusItem,
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,
'life1: 'async_trait,
This function is called once for every consensus item. The function returns an error if any only if the consensus item does not change our state and therefore may be safely discarded by the atomic broadcast.
fn verify_input(&self, input: &DynInput) -> Result<(), DynInputError>
Sourcefn process_input<'a, 'b, 'c, 'life0, 'async_trait>(
&'a self,
dbtx: &'life0 mut DatabaseTransaction<'c>,
input: &'b DynInput,
) -> Pin<Box<dyn Future<Output = Result<InputMeta, DynInputError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'b: 'async_trait,
'c: 'async_trait,
'life0: 'async_trait,
fn process_input<'a, 'b, 'c, 'life0, 'async_trait>(
&'a self,
dbtx: &'life0 mut DatabaseTransaction<'c>,
input: &'b DynInput,
) -> Pin<Box<dyn Future<Output = Result<InputMeta, DynInputError>> + 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.
Sourcefn process_output<'a, 'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'a>,
output: &'life2 DynOutput,
out_point: OutPoint,
) -> Pin<Box<dyn Future<Output = Result<TransactionItemAmount, DynOutputError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn process_output<'a, 'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'a>,
output: &'life2 DynOutput,
out_point: OutPoint,
) -> Pin<Box<dyn Future<Output = Result<TransactionItemAmount, DynOutputError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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
.
Sourcefn output_status<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'life2>,
out_point: OutPoint,
module_instance_id: ModuleInstanceId,
) -> Pin<Box<dyn Future<Output = Option<DynOutputOutcome>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn output_status<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dbtx: &'life1 mut DatabaseTransaction<'life2>,
out_point: OutPoint,
module_instance_id: ModuleInstanceId,
) -> Pin<Box<dyn Future<Output = Option<DynOutputOutcome>> + 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.
Sourcefn 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 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.
Sourcefn api_endpoints(&self) -> Vec<ApiEndpoint<DynServerModule>>
fn api_endpoints(&self) -> Vec<ApiEndpoint<DynServerModule>>
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.