fedimint_core::module

Trait IServerModuleInit

Source
pub trait IServerModuleInit: IDynCommonModuleInit {
    // Required methods
    fn as_common(&self) -> &(dyn IDynCommonModuleInit + Send + Sync + 'static);
    fn supported_api_versions(&self) -> SupportedModuleApiVersions;
    fn init<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer_num: NumPeers,
        cfg: ServerModuleConfig,
        db: Database,
        task_group: &'life1 TaskGroup,
        our_peer_id: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<DynServerModule>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn validate_params(&self, params: &ConfigGenModuleParams) -> Result<()>;
    fn trusted_dealer_gen(
        &self,
        peers: &[PeerId],
        params: &ConfigGenModuleParams,
    ) -> BTreeMap<PeerId, ServerModuleConfig>;
    fn distributed_gen<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        peers: &'life1 PeerHandle<'_>,
        params: &'life2 ConfigGenModuleParams,
    ) -> Pin<Box<dyn Future<Output = DkgResult<ServerModuleConfig>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn validate_config(
        &self,
        identity: &PeerId,
        config: ServerModuleConfig,
    ) -> Result<()>;
    fn get_client_config(
        &self,
        module_instance_id: ModuleInstanceId,
        config: &ServerModuleConsensusConfig,
    ) -> Result<ClientModuleConfig>;
    fn get_database_migrations(
        &self,
    ) -> BTreeMap<DatabaseVersion, CoreMigrationFn>;
}
Expand description

Interface for Module Generation

This trait contains the methods responsible for the module’s

  • initialization
  • config generation
  • config validation

Once the module configuration is ready, the module can be instantiated via [Self::init].

Required Methods§

Source

fn as_common(&self) -> &(dyn IDynCommonModuleInit + Send + Sync + 'static)

Source

fn supported_api_versions(&self) -> SupportedModuleApiVersions

Source

fn init<'life0, 'life1, 'async_trait>( &'life0 self, peer_num: NumPeers, cfg: ServerModuleConfig, db: Database, task_group: &'life1 TaskGroup, our_peer_id: PeerId, ) -> Pin<Box<dyn Future<Output = Result<DynServerModule>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Initialize the DynServerModule instance from its config

Source

fn validate_params(&self, params: &ConfigGenModuleParams) -> Result<()>

Source

fn trusted_dealer_gen( &self, peers: &[PeerId], params: &ConfigGenModuleParams, ) -> BTreeMap<PeerId, ServerModuleConfig>

Source

fn distributed_gen<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, peers: &'life1 PeerHandle<'_>, params: &'life2 ConfigGenModuleParams, ) -> Pin<Box<dyn Future<Output = DkgResult<ServerModuleConfig>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn validate_config( &self, identity: &PeerId, config: ServerModuleConfig, ) -> Result<()>

Source

fn get_client_config( &self, module_instance_id: ModuleInstanceId, config: &ServerModuleConsensusConfig, ) -> Result<ClientModuleConfig>

Source

fn get_database_migrations(&self) -> BTreeMap<DatabaseVersion, CoreMigrationFn>

Retrieves the migrations map from the server module to be applied to the database before the module is initialized. The migrations map is indexed on the from version.

Implementors§

Source§

impl<T> IServerModuleInit for T
where T: ServerModuleInit + 'static + Sync,