mirror of
https://github.com/wealdtech/ethdo.git
synced 2026-01-09 14:07:56 -05:00
Merge pull request #134 from lyfsn/max-distance-var
Add maxDistance as an input parameter
This commit is contained in:
@@ -48,6 +48,7 @@ type command struct {
|
||||
genesisValidatorsRoot string
|
||||
prepareOffline bool
|
||||
signedOperationsInput string
|
||||
maxDistance uint64
|
||||
|
||||
// Beacon node connection.
|
||||
timeout time.Duration
|
||||
@@ -90,6 +91,7 @@ func newCommand(_ context.Context) (*command, error) {
|
||||
withdrawalAddressStr: viper.GetString("withdrawal-address"),
|
||||
forkVersion: viper.GetString("fork-version"),
|
||||
genesisValidatorsRoot: viper.GetString("genesis-validators-root"),
|
||||
maxDistance: viper.GetUint64("max-distance"),
|
||||
}
|
||||
|
||||
// Timeout is required.
|
||||
|
||||
@@ -197,6 +197,9 @@ func (c *command) generateOperationFromMnemonicAndValidator(ctx context.Context)
|
||||
|
||||
// Scan the keys from the seed to find the path.
|
||||
maxDistance := 1024
|
||||
if c.maxDistance > 0 {
|
||||
maxDistance = int(c.maxDistance)
|
||||
}
|
||||
// Start scanning the validator keys.
|
||||
var withdrawalAccount e2wtypes.Account
|
||||
for i := 0; ; i++ {
|
||||
@@ -247,10 +250,13 @@ func (c *command) generateOperationsFromMnemonic(ctx context.Context) error {
|
||||
validators[fmt.Sprintf("%#x", validator.Pubkey)] = validator
|
||||
}
|
||||
|
||||
maxDistance := 1024
|
||||
// Start scanning the validator keys.
|
||||
lastFoundIndex := 0
|
||||
foundValidatorCount := 0
|
||||
maxDistance := 1024
|
||||
if c.maxDistance > 0 {
|
||||
maxDistance = int(c.maxDistance)
|
||||
}
|
||||
for i := 0; ; i++ {
|
||||
// If no validators have been found in the last maxDistance indices, stop scanning.
|
||||
if i-lastFoundIndex > maxDistance {
|
||||
|
||||
@@ -44,6 +44,7 @@ type command struct {
|
||||
prepareOffline bool
|
||||
signedOperationsInput string
|
||||
epoch string
|
||||
maxDistance uint64
|
||||
|
||||
// Beacon node connection.
|
||||
timeout time.Duration
|
||||
@@ -82,6 +83,7 @@ func newCommand(_ context.Context) (*command, error) {
|
||||
forkVersion: viper.GetString("fork-version"),
|
||||
genesisValidatorsRoot: viper.GetString("genesis-validators-root"),
|
||||
epoch: viper.GetString("epoch"),
|
||||
maxDistance: viper.GetUint64("max-distance"),
|
||||
signedOperations: make([]*phase0.SignedVoluntaryExit, 0),
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +177,9 @@ func (c *command) generateOperationFromMnemonicAndValidator(ctx context.Context)
|
||||
|
||||
// Scan the keys from the seed to find the path.
|
||||
maxDistance := 1024
|
||||
if c.maxDistance > 0 {
|
||||
maxDistance = int(c.maxDistance)
|
||||
}
|
||||
// Start scanning the validator keys.
|
||||
for i := 0; ; i++ {
|
||||
if i == maxDistance {
|
||||
@@ -219,7 +222,11 @@ func (c *command) generateOperationsFromMnemonic(ctx context.Context) error {
|
||||
validators[fmt.Sprintf("%#x", validator.Pubkey)] = validator
|
||||
}
|
||||
|
||||
// Scan the keys from the seed to find the path.
|
||||
maxDistance := 1024
|
||||
if c.maxDistance > 0 {
|
||||
maxDistance = int(c.maxDistance)
|
||||
}
|
||||
// Start scanning the validator keys.
|
||||
lastFoundIndex := 0
|
||||
foundValidatorCount := 0
|
||||
|
||||
@@ -64,6 +64,7 @@ func init() {
|
||||
validatorCredentialsSetCmd.Flags().Bool("offline", false, "Do not attempt to connect to a beacon node to obtain information for the operation")
|
||||
validatorCredentialsSetCmd.Flags().String("fork-version", "", "Fork version to use for signing (overrides fetching from beacon node)")
|
||||
validatorCredentialsSetCmd.Flags().String("genesis-validators-root", "", "Genesis validators root to use for signing (overrides fetching from beacon node)")
|
||||
validatorCredentialsSetCmd.Flags().Uint64("max-distance", 1024, "Maximum indices to scan for finding the validator.")
|
||||
}
|
||||
|
||||
func validatorCredentialsSetBindings(cmd *cobra.Command) {
|
||||
@@ -91,4 +92,7 @@ func validatorCredentialsSetBindings(cmd *cobra.Command) {
|
||||
if err := viper.BindPFlag("genesis-validators-root", cmd.Flags().Lookup("genesis-validators-root")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := viper.BindPFlag("max-distance", cmd.Flags().Lookup("max-distance")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func init() {
|
||||
validatorExitCmd.Flags().Bool("offline", false, "Do not attempt to connect to a beacon node to obtain information for the operation")
|
||||
validatorExitCmd.Flags().String("fork-version", "", "Fork version to use for signing (overrides fetching from beacon node)")
|
||||
validatorExitCmd.Flags().String("genesis-validators-root", "", "Genesis validators root to use for signing (overrides fetching from beacon node)")
|
||||
validatorExitCmd.Flags().Uint64("max-distance", 1024, "Maximum indices to scan for finding the validator.")
|
||||
}
|
||||
|
||||
func validatorExitBindings(cmd *cobra.Command) {
|
||||
@@ -88,4 +89,7 @@ func validatorExitBindings(cmd *cobra.Command) {
|
||||
if err := viper.BindPFlag("genesis-validators-root", cmd.Flags().Lookup("genesis-validators-root")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := viper.BindPFlag("max-distance", cmd.Flags().Lookup("max-distance")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user