Trait fedimint_core::module::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, ServerMigrationFn>;
}
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, ServerMigrationFn>

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,