Prefill GetTipsetByHeight skiplist cache on lotus startup
This commit is contained in:
parent
fc0df4afb8
commit
a27e0a8b41
@ -4,9 +4,12 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/ethhashlookup"
|
||||
"github.com/filecoin-project/lotus/chain/events"
|
||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
||||
@ -54,6 +57,17 @@ func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRep
|
||||
}
|
||||
}
|
||||
|
||||
// prefill the whole skiplist cache maintained internally by the GetTipsetByHeight
|
||||
go func() {
|
||||
start := time.Now()
|
||||
log.Infoln("Start prefilling GetTipsetByHeight cache")
|
||||
_, err := cs.GetTipsetByHeight(mctx, abi.ChainEpoch(0), cs.GetHeaviestTipSet(), false)
|
||||
if err != nil {
|
||||
log.Warnf("error when prefilling GetTipsetByHeight cache: %w", err)
|
||||
}
|
||||
log.Infof("Prefilling GetTipsetByHeight done in %s", time.Since(start))
|
||||
}()
|
||||
|
||||
ctx := helpers.LifecycleCtx(mctx, lc)
|
||||
lc.Append(fx.Hook{
|
||||
OnStart: func(context.Context) error {
|
||||
|
Loading…
Reference in New Issue
Block a user