diff --git a/cmd/thalos/server.go b/cmd/thalos/server.go index 3a98d24..aa10fac 100644 --- a/cmd/thalos/server.go +++ b/cmd/thalos/server.go @@ -154,7 +154,7 @@ func initAbiManager(api *eos.API, store cache.Store, chain_id string) *abi.AbiMa return abi.NewAbiManager(cache, api) } -func stateLoader(conf *config.Config, chainInfo *eos.InfoResp, cache *cache.Cache, current_block_no_cache bool) StateLoader { +func stateLoader(conf *config.Config, start_block_flag *pflag.Flag, chainInfo *eos.InfoResp, cache *cache.Cache, current_block_no_cache bool) StateLoader { return func(state *State) { var source string @@ -168,7 +168,13 @@ func stateLoader(conf *config.Config, chainInfo *eos.InfoResp, cache *cache.Cach 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" + + if start_block_flag != nil && start_block_flag.Changed { + source = "cli" + } else { + source = "config" + } + state.CurrentBlock = conf.Ship.StartBlockNum } else { // Otherwise, set from api. @@ -355,7 +361,7 @@ func serverCmd(cmd *cobra.Command, args []string) { processor := SpawnProccessor( shClient, - stateLoader(conf, chainInfo, cache, skip_currentblock_cache), + stateLoader(conf, cmd.Flags().Lookup("start-block"), chainInfo, cache, skip_currentblock_cache), stateSaver(cache), driver.NewPublisher(context.Background(), rdb, api_redis.Namespace{ Prefix: conf.Redis.Prefix,