mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
7cc32c4dda
* remove unused code * remove defer use in loop * Remove unused methods and constants * gofmt and gaz * nilness check * remove unused args * Add TODO for refactoring subscribeWithBase to remove unused arg. It seems too involved to include in this sweeping PR. https://github.com/prysmaticlabs/prysm/issues/7437 * replace empty slice declaration * Remove unnecessary type conversions * remove redundant type declaration * rename receivers to be consistent * Remove bootnode query tool. It is now obsolete by discv5 * Remove relay node. It is no longer used or supported * Revert "Remove relay node. It is no longer used or supported" This reverts commit 4bd7717334dad85ef4766ed9bc4da711fb5fa810. * Delete unused test directory * Delete unsupported gcp startup script * Delete old k8s script * build fixes * fix build * go mod tidy * revert slasher/db/kv/block_header.go * fix build * remove redundant nil check * combine func args Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
package flags
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// GlobalFlags specifies all the global flags for the
|
|
// beacon node.
|
|
type GlobalFlags struct {
|
|
UnsafeSync bool
|
|
DisableSync bool
|
|
DisableDiscv5 bool
|
|
MinimumSyncPeers int
|
|
BlockBatchLimit int
|
|
BlockBatchLimitBurstFactor int
|
|
}
|
|
|
|
var globalConfig *GlobalFlags
|
|
|
|
// Get retrieves the global config.
|
|
func Get() *GlobalFlags {
|
|
if globalConfig == nil {
|
|
return &GlobalFlags{}
|
|
}
|
|
return globalConfig
|
|
}
|
|
|
|
// Init sets the global config equal to the config that is passed in.
|
|
func Init(c *GlobalFlags) {
|
|
globalConfig = c
|
|
}
|
|
|
|
// ConfigureGlobalFlags initializes the global config.
|
|
// based on the provided cli context.
|
|
func ConfigureGlobalFlags(ctx *cli.Context) {
|
|
cfg := &GlobalFlags{}
|
|
if ctx.Bool(UnsafeSync.Name) {
|
|
log.Warn("Using Unsafe Sync flag, it is insecure to use this flag with your beacon node.")
|
|
cfg.UnsafeSync = true
|
|
}
|
|
if ctx.Bool(DisableSync.Name) {
|
|
log.Warn("Using Disable Sync flag, using this flag on a live network might lead to adverse consequences.")
|
|
cfg.DisableSync = true
|
|
}
|
|
cfg.DisableDiscv5 = ctx.Bool(DisableDiscv5.Name)
|
|
cfg.BlockBatchLimit = ctx.Int(BlockBatchLimit.Name)
|
|
cfg.BlockBatchLimitBurstFactor = ctx.Int(BlockBatchLimitBurstFactor.Name)
|
|
configureMinimumPeers(ctx, cfg)
|
|
|
|
Init(cfg)
|
|
}
|
|
|
|
func configureMinimumPeers(ctx *cli.Context, cfg *GlobalFlags) {
|
|
cfg.MinimumSyncPeers = ctx.Int(MinSyncPeers.Name)
|
|
maxPeers := ctx.Int(cmd.P2PMaxPeers.Name)
|
|
if cfg.MinimumSyncPeers > maxPeers {
|
|
log.Warnf("Changing Minimum Sync Peers to %d", maxPeers)
|
|
cfg.MinimumSyncPeers = maxPeers
|
|
}
|
|
}
|