2024-01-23 07:54:30 +00:00
|
|
|
package backfill
|
|
|
|
|
|
|
|
import (
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/node"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/backfill"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/sync/backfill/flags"
|
2024-03-15 15:17:24 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
2024-01-23 07:54:30 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BeaconNodeOptions sets the appropriate functional opts on the *node.BeaconNode value, to decouple options
|
|
|
|
// from flag parsing.
|
|
|
|
func BeaconNodeOptions(c *cli.Context) ([]node.Option, error) {
|
|
|
|
opt := func(node *node.BeaconNode) (err error) {
|
2024-03-15 15:17:24 +00:00
|
|
|
bno := []backfill.ServiceOption{
|
2024-01-26 04:37:41 +00:00
|
|
|
backfill.WithBatchSize(c.Uint64(flags.BackfillBatchSize.Name)),
|
|
|
|
backfill.WithWorkerCount(c.Int(flags.BackfillWorkerCount.Name)),
|
|
|
|
backfill.WithEnableBackfill(c.Bool(flags.EnableExperimentalBackfill.Name)),
|
2024-01-23 07:54:30 +00:00
|
|
|
}
|
2024-03-15 15:17:24 +00:00
|
|
|
// The zero value of this uint flag would be genesis, so we use IsSet to differentiate nil from zero case.
|
|
|
|
if c.IsSet(flags.BackfillOldestSlot.Name) {
|
|
|
|
uv := c.Uint64(flags.BackfillBatchSize.Name)
|
|
|
|
bno = append(bno, backfill.WithMinimumSlot(primitives.Slot(uv)))
|
|
|
|
}
|
|
|
|
node.BackfillOpts = bno
|
2024-01-23 07:54:30 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return []node.Option{opt}, nil
|
|
|
|
}
|