feat: introduce PreBlock (#17421)
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
// Config should never need to be instantiated manually and is solely used for ModuleOption.
|
||||
type Config struct {
|
||||
ModuleConfigs map[string]*appv1alpha1.ModuleConfig
|
||||
PreBlockersOrder []string
|
||||
BeginBlockersOrder []string
|
||||
EndBlockersOrder []string
|
||||
InitGenesisOrder []string
|
||||
@@ -37,8 +38,10 @@ type Config struct {
|
||||
func defaultConfig() *Config {
|
||||
return &Config{
|
||||
ModuleConfigs: make(map[string]*appv1alpha1.ModuleConfig),
|
||||
BeginBlockersOrder: []string{
|
||||
PreBlockersOrder: []string{
|
||||
"upgrade",
|
||||
},
|
||||
BeginBlockersOrder: []string{
|
||||
"mint",
|
||||
"distribution",
|
||||
"slashing",
|
||||
@@ -106,6 +109,12 @@ func defaultConfig() *Config {
|
||||
|
||||
type ModuleOption func(config *Config)
|
||||
|
||||
func WithCustomPreBlockersOrder(preBlockOrder ...string) ModuleOption {
|
||||
return func(config *Config) {
|
||||
config.PreBlockersOrder = preBlockOrder
|
||||
}
|
||||
}
|
||||
|
||||
func WithCustomBeginBlockersOrder(beginBlockOrder ...string) ModuleOption {
|
||||
return func(config *Config) {
|
||||
config.BeginBlockersOrder = beginBlockOrder
|
||||
@@ -315,11 +324,18 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config {
|
||||
opt(cfg)
|
||||
}
|
||||
|
||||
preBlockers := make([]string, 0)
|
||||
beginBlockers := make([]string, 0)
|
||||
endBlockers := make([]string, 0)
|
||||
initGenesis := make([]string, 0)
|
||||
overrides := make([]*runtimev1alpha1.StoreKeyConfig, 0)
|
||||
|
||||
for _, s := range cfg.PreBlockersOrder {
|
||||
if _, ok := cfg.ModuleConfigs[s]; ok {
|
||||
preBlockers = append(preBlockers, s)
|
||||
}
|
||||
}
|
||||
|
||||
for _, s := range cfg.BeginBlockersOrder {
|
||||
if _, ok := cfg.ModuleConfigs[s]; ok {
|
||||
beginBlockers = append(beginBlockers, s)
|
||||
@@ -344,6 +360,7 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config {
|
||||
|
||||
runtimeConfig := &runtimev1alpha1.Module{
|
||||
AppName: "TestApp",
|
||||
PreBlockers: preBlockers,
|
||||
BeginBlockers: beginBlockers,
|
||||
EndBlockers: endBlockers,
|
||||
OverrideStoreKeys: overrides,
|
||||
|
||||
Reference in New Issue
Block a user