1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00

cmd/thalos/server.go: in stateLoader(): set "cli" as source if start block is set via cli flag.

This commit is contained in:
Henrik Hautakoski 2024-02-18 18:09:12 +01:00
parent 146ea99298
commit fb3b35cbe9

View file

@ -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,