refactor: modules should implement appmodule.AppModule (#18252)
This commit is contained in:
@@ -19,20 +19,26 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ appmodule.AppModule = coreAppModuleBasicAdaptor{}
|
||||
|
||||
_ AppModuleBasic = coreAppModuleBasicAdaptor{}
|
||||
_ HasABCIGenesis = coreAppModuleBasicAdaptor{}
|
||||
_ HasServices = coreAppModuleBasicAdaptor{}
|
||||
)
|
||||
|
||||
// CoreAppModuleBasicAdaptor wraps the core API module as an AppModule that this version
|
||||
// of the SDK can use.
|
||||
func CoreAppModuleBasicAdaptor(name string, module appmodule.AppModule) AppModuleBasic {
|
||||
// CoreAppModuleAdaptor wraps the core API module as an AppModule that this version of the SDK can use.
|
||||
func CoreAppModuleAdaptor(name string, module appmodule.AppModule) AppModule {
|
||||
return coreAppModuleBasicAdaptor{
|
||||
name: name,
|
||||
module: module,
|
||||
}
|
||||
}
|
||||
|
||||
// CoreAppModuleBasicAdaptor wraps the core API module as an AppModule that this version of the SDK can use.
|
||||
func CoreAppModuleBasicAdaptor(name string, module appmodule.AppModule) AppModule {
|
||||
return CoreAppModuleAdaptor(name, module)
|
||||
}
|
||||
|
||||
type coreAppModuleBasicAdaptor struct {
|
||||
name string
|
||||
module appmodule.AppModule
|
||||
@@ -195,3 +201,7 @@ func (c coreAppModuleBasicAdaptor) RegisterServices(cfg Configurator) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c coreAppModuleBasicAdaptor) IsOnePerModuleType() {}
|
||||
|
||||
func (c coreAppModuleBasicAdaptor) IsAppModule() {}
|
||||
|
||||
@@ -199,6 +199,8 @@ type HasABCIGenesis interface {
|
||||
// its functionality has been moved to extension interfaces.
|
||||
// Deprecated: use appmodule.AppModule with a combination of extension interfaes interfaces instead.
|
||||
type AppModule interface {
|
||||
appmodule.AppModule
|
||||
|
||||
AppModuleBasic
|
||||
}
|
||||
|
||||
@@ -288,6 +290,10 @@ func NewManager(modules ...AppModule) *Manager {
|
||||
modulesStr := make([]string, 0, len(modules))
|
||||
preBlockModulesStr := make([]string, 0)
|
||||
for _, module := range modules {
|
||||
if _, ok := module.(appmodule.AppModule); !ok {
|
||||
panic(fmt.Sprintf("module %s does not implement appmodule.AppModule", module.Name()))
|
||||
}
|
||||
|
||||
moduleMap[module.Name()] = module
|
||||
modulesStr = append(modulesStr, module.Name())
|
||||
if _, ok := module.(appmodule.HasPreBlocker); ok {
|
||||
|
||||
Reference in New Issue
Block a user