feat(core): add migrations registering (#19370)
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
This commit is contained in:
co-authored by
Facundo Medica
parent
ac48269f98
commit
e15a0de251
@@ -0,0 +1,16 @@
|
||||
package appmodule
|
||||
|
||||
import "context"
|
||||
|
||||
type MigrationRegistrar interface {
|
||||
// Register registers an in-place store migration for a module. The
|
||||
// handler is a migration script to perform in-place migrations from version
|
||||
// `fromVersion` to version `fromVersion+1`.
|
||||
//
|
||||
// EACH TIME a module's ConsensusVersion increments, a new migration MUST
|
||||
// be registered using this function. If a migration handler is missing for
|
||||
// a particular function, the upgrade logic (see RunMigrations function)
|
||||
// will panic. If the ConsensusVersion bump does not introduce any store
|
||||
// changes, then a no-op function must be registered here.
|
||||
Register(moduleName string, fromVersion uint64, handler func(context.Context) error) error
|
||||
}
|
||||
@@ -39,17 +39,12 @@ type HasServices interface {
|
||||
RegisterServices(grpc.ServiceRegistrar) error
|
||||
}
|
||||
|
||||
// HasPrepareCheckState is an extension interface that contains information about the AppModule
|
||||
// and PrepareCheckState.
|
||||
type HasPrepareCheckState interface {
|
||||
// HasMigrations is the extension interface that modules should implement to register migrations.
|
||||
type HasMigrations interface {
|
||||
AppModule
|
||||
PrepareCheckState(context.Context) error
|
||||
}
|
||||
|
||||
// HasPrecommit is an extension interface that contains information about the AppModule and Precommit.
|
||||
type HasPrecommit interface {
|
||||
AppModule
|
||||
Precommit(context.Context) error
|
||||
// RegisterMigrations registers the module's migrations with the app's migrator.
|
||||
RegisterMigrations(MigrationRegistrar) error
|
||||
}
|
||||
|
||||
// ResponsePreBlock represents the response from the PreBlock method.
|
||||
@@ -100,3 +95,18 @@ type HasMsgHandler interface {
|
||||
// RegisterMsgHandlers is implemented by the module that will register msg handlers.
|
||||
RegisterMsgHandlers(router MsgHandlerRouter)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------- //
|
||||
|
||||
// HasPrepareCheckState is an extension interface that contains information about the AppModule
|
||||
// and PrepareCheckState.
|
||||
type HasPrepareCheckState interface {
|
||||
AppModule
|
||||
PrepareCheckState(context.Context) error
|
||||
}
|
||||
|
||||
// HasPrecommit is an extension interface that contains information about the AppModule and Precommit.
|
||||
type HasPrecommit interface {
|
||||
AppModule
|
||||
Precommit(context.Context) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user