fedimint_core::module

Trait ServerModuleInit

Source
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§

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 parse_params(&self, params: &ConfigGenModuleParams) -> Result<Self::Params>

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.

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.

Implementors§