mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-17 04:30:03 +02:00
cmd/thalos/main.go: pass context to cache.
This commit is contained in:
parent
1d5e28a38f
commit
41ab39d4a3
1 changed files with 6 additions and 2 deletions
|
|
@ -187,7 +187,9 @@ func stateLoader(chainInfo *eos.InfoResp, current_block_no_cache bool) app.State
|
|||
var source string
|
||||
|
||||
// Load state from cache.
|
||||
err := cache.Get("state", &state)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
|
||||
err := cache.Get(ctx, "state", &state)
|
||||
cancel()
|
||||
|
||||
// on error (cache miss) or if current_block_no_cache is set.
|
||||
// set current block from config/api
|
||||
|
|
@ -218,7 +220,9 @@ func stateLoader(chainInfo *eos.InfoResp, current_block_no_cache bool) app.State
|
|||
}
|
||||
|
||||
func stateSaver(state app.State) error {
|
||||
return cache.Set("state", state, 0)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
|
||||
defer cancel()
|
||||
return cache.Set(ctx, "state", state, 0)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue