From 1daf38bd3d92cc5c8fa3f0b505b2ef96c7d2667d Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 4 Nov 2023 13:32:32 +0100 Subject: [PATCH] cmd/thalos/main.go: adding "-n" flag to force current block from config/api. --- cmd/thalos/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/thalos/main.go b/cmd/thalos/main.go index df9c814..60d7de7 100644 --- a/cmd/thalos/main.go +++ b/cmd/thalos/main.go @@ -182,15 +182,16 @@ func initAbiManger(api *eos.API, chain_id string) *abi.AbiManager { return abi.NewAbiManager(cache, api) } -func stateLoader(chainInfo *eos.InfoResp) app.StateLoader { +func stateLoader(chainInfo *eos.InfoResp, current_block_no_cache bool) app.StateLoader { return func(state *app.State) { var source string // Load state from cache. err := cache.Get("state", &state) - // on error (cache miss) set current block from config/api - if err != nil { + // on error (cache miss) or if current_block_no_cache is set. + // set current block from config/api + if current_block_no_cache || err != nil { // Set from config if we have a sane value. if conf.Ship.StartBlockNum != shipclient.NULL_BLOCK_NUMBER { source = "config" @@ -232,6 +233,7 @@ func main() { pidFile := getopt.StringLong("pid", 'p', "", "Where to write process id", "file") logFile := getopt.StringLong("log", 'l', "", "Path to log file", "file") logLevel := getopt.EnumLong("level", 'L', LogLevels(), "info", "Log level to use") + skip_currentblock_cache := getopt.Bool('n', "Force the application to take start block from config/api") getopt.Parse() @@ -365,7 +367,7 @@ func main() { processor := app.SpawnProccessor( shClient, - stateLoader(chainInfo), + stateLoader(chainInfo, *skip_currentblock_cache), stateSaver, api_redis.NewPublisher(context.Background(), rdb, api_redis.Namespace{ Prefix: conf.Redis.Prefix,