Replace a Few IntFlags with Uint64Flags (#9959)

* use uints instead of ints

* fix method

* fix

* fix

* builds

* deepsource

* deep source
This commit is contained in:
Raul Jordan
2021-12-01 18:34:53 -05:00
committed by GitHub
parent ab60b1c7b2
commit 790bf03123
25 changed files with 57 additions and 58 deletions

View File

@@ -88,7 +88,7 @@ var (
}
// MinSyncPeers specifies the required number of successful peer handshakes in order
// to start syncing with external peers.
MinSyncPeers = &cli.IntFlag{
MinSyncPeers = &cli.Uint64Flag{
Name: "min-sync-peers",
Usage: "The required number of valid peers to connect with before syncing.",
Value: 3,
@@ -123,13 +123,13 @@ var (
Usage: "Does not run the discoveryV5 dht.",
}
// BlockBatchLimit specifies the requested block batch size.
BlockBatchLimit = &cli.IntFlag{
BlockBatchLimit = &cli.Uint64Flag{
Name: "block-batch-limit",
Usage: "The amount of blocks the local peer is bounded to request and respond to in a batch.",
Value: 64,
}
// BlockBatchLimitBurstFactor specifies the factor by which block batch size may increase.
BlockBatchLimitBurstFactor = &cli.IntFlag{
BlockBatchLimitBurstFactor = &cli.Uint64Flag{
Name: "block-batch-limit-burst-factor",
Usage: "The factor by which block batch limit may increase on burst.",
Value: 10,

View File

@@ -12,10 +12,10 @@ type GlobalFlags struct {
DisableSync bool
DisableDiscv5 bool
SubscribeToAllSubnets bool
MinimumSyncPeers int
MinimumPeersPerSubnet int
BlockBatchLimit int
BlockBatchLimitBurstFactor int
MinimumSyncPeers uint64
MinimumPeersPerSubnet uint64
BlockBatchLimit uint64
BlockBatchLimitBurstFactor uint64
}
var globalConfig *GlobalFlags
@@ -50,17 +50,17 @@ func ConfigureGlobalFlags(ctx *cli.Context) {
cfg.SubscribeToAllSubnets = true
}
cfg.DisableDiscv5 = ctx.Bool(DisableDiscv5.Name)
cfg.BlockBatchLimit = ctx.Int(BlockBatchLimit.Name)
cfg.BlockBatchLimitBurstFactor = ctx.Int(BlockBatchLimitBurstFactor.Name)
cfg.MinimumPeersPerSubnet = ctx.Int(MinPeersPerSubnet.Name)
cfg.BlockBatchLimit = ctx.Uint64(BlockBatchLimit.Name)
cfg.BlockBatchLimitBurstFactor = ctx.Uint64(BlockBatchLimitBurstFactor.Name)
cfg.MinimumPeersPerSubnet = ctx.Uint64(MinPeersPerSubnet.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)
cfg.MinimumSyncPeers = ctx.Uint64(MinSyncPeers.Name)
maxPeers := ctx.Uint64(cmd.P2PMaxPeers.Name)
if cfg.MinimumSyncPeers > maxPeers {
log.Warnf("Changing Minimum Sync Peers to %d", maxPeers)
cfg.MinimumSyncPeers = maxPeers