pub trait ServerModuleInit: ModuleInit + Sized {
type Params: ModuleInitParams;
// Required methods
fn versions(&self, core: CoreConsensusVersion) -> &[ModuleConsensusVersion];
fn supported_api_versions(&self) -> SupportedModuleApiVersions;
fn init<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 ServerModuleInitArgs<Self>,
) -> Pin<Box<dyn Future<Output = Result<DynServerModule>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn trusted_dealer_gen(
&self,
peers: &[PeerId],
params: &ConfigGenModuleParams,
) -> BTreeMap<PeerId, ServerModuleConfig>;
fn distributed_gen<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
peer: &'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,
config: &ServerModuleConsensusConfig,
) -> Result<<<Self as ModuleInit>::Common as CommonModuleInit>::ClientConfig>;
// Provided methods
fn kind() -> ModuleKind { ... }
fn parse_params(
&self,
params: &ConfigGenModuleParams,
) -> Result<Self::Params> { ... }
fn get_database_migrations(
&self,
) -> BTreeMap<DatabaseVersion, CoreMigrationFn> { ... }
}
Expand description
Module Generation trait with associated types
Needs to be implemented by module generation type
For examples, take a look at one of the MintConfigGenerator
,
WalletConfigGenerator
, or LightningConfigGenerator
structs.
Required Associated Types§
type Params: ModuleInitParams
Required Methods§
Sourcefn versions(&self, core: CoreConsensusVersion) -> &[ModuleConsensusVersion]
fn versions(&self, core: CoreConsensusVersion) -> &[ModuleConsensusVersion]
Version of the module consensus supported by this implementation given a
certain CoreConsensusVersion
.
Refer to ModuleConsensusVersion
for more information about
versioning.
One module implementation (ServerModuleInit
of a given
ModuleKind
) can potentially implement multiple versions of the
consensus, and depending on the config module instance config,
instantiate the desired one. This method should expose all the
available versions, purely for information, setup UI and sanity
checking purposes.
fn supported_api_versions(&self) -> SupportedModuleApiVersions
Sourcefn init<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 ServerModuleInitArgs<Self>,
) -> 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,
args: &'life1 ServerModuleInitArgs<Self>,
) -> 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 trusted_dealer_gen( &self, peers: &[PeerId], params: &ConfigGenModuleParams, ) -> BTreeMap<PeerId, ServerModuleConfig>
fn distributed_gen<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
peer: &'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<()>
Sourcefn get_client_config(
&self,
config: &ServerModuleConsensusConfig,
) -> Result<<<Self as ModuleInit>::Common as CommonModuleInit>::ClientConfig>
fn get_client_config( &self, config: &ServerModuleConsensusConfig, ) -> Result<<<Self as ModuleInit>::Common as CommonModuleInit>::ClientConfig>
Converts the consensus config into the client config
Provided Methods§
fn kind() -> ModuleKind
fn parse_params(&self, params: &ConfigGenModuleParams) -> Result<Self::Params>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.