From 0af2fa595c57d76d5577d50142357b531748e993 Mon Sep 17 00:00:00 2001 From: tuky191 Date: Tue, 8 Aug 2023 22:05:08 +0200 Subject: [PATCH] add option to skip heights --- config/config.go | 15 +++++++++++++++ sync.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index a67aa25..c72849e 100644 --- a/config/config.go +++ b/config/config.go @@ -26,6 +26,7 @@ type Config struct { EnableExportModule bool RichlistLength int RichlistThreshold *sdk.Coin + SkipUpgradeHeights map[int64]bool } var singleton Config @@ -115,6 +116,20 @@ func newConfig() Config { } return &thresholdCoin }(), + SkipUpgradeHeights: func() map[int64]bool { + skipUpgradeHeightsStr := getValidEnv("SKIP_UPGRADE_HEIGHTS") + heightsMap := make(map[int64]bool) + + heights := strings.Split(skipUpgradeHeightsStr, ",") + for _, h := range heights { + height, err := strconv.ParseInt(h, 10, 64) + if err != nil { + panic(fmt.Errorf("invalid height in SKIP_UPGRADE_HEIGHTS: %s", h)) + } + heightsMap[height] = true + } + return heightsMap + }(), } viper.SetConfigType("toml") diff --git a/sync.go b/sync.go index b4afe39..4ef243c 100644 --- a/sync.go +++ b/sync.go @@ -92,7 +92,7 @@ func main() { batched, nil, true, // need this so KVStores are set - make(map[int64]bool), + mantlemintConfig.SkipUpgradeHeights, mantlemintConfig.Home, 0, codec,