pub trait ServerModuleInit: ModuleInit + Sized {
    type Params: ModuleInitParams;

    const DATABASE_VERSION: DatabaseVersion;

    // 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 get_database_migrations(&self) -> MigrationMap { ... }
    fn parse_params(
        &self,
        params: &ConfigGenModuleParams
    ) -> Result<Self::Params> { ... }
}
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§

Required Associated Constants§

source

const DATABASE_VERSION: DatabaseVersion

This represents the module’s database version that the current code is compatible with. It is important to increment this value whenever a key or a value that is persisted to the database within the module changes. It is also important to add the corresponding migration function in get_database_migrations which should define how to move from the previous database version to the current version.

Required Methods§

source

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.

source

fn supported_api_versions(&self) -> SupportedModuleApiVersions

source

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

source

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

source

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,

source

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

source

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§

source

fn kind() -> ModuleKind

source

fn get_database_migrations(&self) -> MigrationMap

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

source

fn parse_params(&self, params: &ConfigGenModuleParams) -> Result<Self::Params>

Object Safety§

This trait is not object safe.

Implementors§