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§
fn as_common(&self) -> &(dyn IDynCommonModuleInit + Send + Sync + 'static)
fn supported_api_versions(&self) -> SupportedModuleApiVersions
Sourcefn 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 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
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>
Sourcefn get_database_migrations(&self) -> BTreeMap<DatabaseVersion, CoreMigrationFn>
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.