diff --git a/tools/genesis-snapshot/main.go b/tools/genesis-snapshot/main.go index 01a0d6af7..c87ab179a 100644 --- a/tools/genesis-snapshot/main.go +++ b/tools/genesis-snapshot/main.go @@ -18,11 +18,11 @@ func main() { parsedOpts, configSelected := parseFlags() opts := presets.Base if strings.Contains(configSelected, ".yml") { - if yamlOpts, err := presets.GenerateFromYaml(configSelected); err != nil { + yamlOpts, err := presets.GenerateFromYaml(configSelected) + if err != nil { panic(err) - } else { - opts = append(opts, yamlOpts...) } + opts = append(opts, yamlOpts...) } else { switch configSelected { case "docker": diff --git a/tools/genesis-snapshot/presets/presets.go b/tools/genesis-snapshot/presets/presets.go index 97934ebc0..9b40eeb7b 100644 --- a/tools/genesis-snapshot/presets/presets.go +++ b/tools/genesis-snapshot/presets/presets.go @@ -16,19 +16,19 @@ import ( ) var ( - // use defaults from iota.go + // use defaults from iota.go. protocolParamsBase = iotago.NewV3SnapshotProtocolParameters( iotago.WithNetworkOptions("default", iotago.PrefixTestnet), ) - // use defaults from iota.go + // use defaults from iota.go. protocolParamsDocker = iotago.NewV3SnapshotProtocolParameters( iotago.WithNetworkOptions("docker", iotago.PrefixTestnet), iotago.WithTimeProviderOptions(5, time.Now().Unix(), 10, 7), iotago.WithLivenessOptions(10, 15, 3, 6, 8), ) - // use defaults from iota.go + // use defaults from iota.go. protocolParamsFeature = iotago.NewV3SnapshotProtocolParameters( iotago.WithNetworkOptions("feature", iotago.PrefixTestnet), iotago.WithTimeProviderOptions(666666, time.Now().Unix()-100_000, 10, 13), diff --git a/tools/genesis-snapshot/presets/presets_yaml.go b/tools/genesis-snapshot/presets/presets_yaml.go index 5f1918f1e..f6445dfdf 100644 --- a/tools/genesis-snapshot/presets/presets_yaml.go +++ b/tools/genesis-snapshot/presets/presets_yaml.go @@ -17,12 +17,12 @@ import ( type ValidatorYaml struct { Name string `yaml:"name"` - PublicKey string `yaml:"public-key"` + PublicKey string `yaml:"publicKey"` } type BlockIssuerYaml struct { Name string `yaml:"name"` - PublicKey string `yaml:"public-key"` + PublicKey string `yaml:"publicKey"` } type BasicOutputYaml struct { @@ -36,8 +36,8 @@ type ConfigYaml struct { FilePath string `yaml:"filepath"` Validators []ValidatorYaml `yaml:"validators"` - BlockIssuers []BlockIssuerYaml `yaml:"block-issuers"` - BasicOutputs []BasicOutputYaml `yaml:"basic-outputs"` + BlockIssuers []BlockIssuerYaml `yaml:"blockIssuers"` + BasicOutputs []BasicOutputYaml `yaml:"basicOutputs"` } func GenerateFromYaml(hostsFile string) ([]options.Option[snapshotcreator.Options], error) { @@ -46,7 +46,7 @@ func GenerateFromYaml(hostsFile string) ([]options.Option[snapshotcreator.Option return nil, err } - var accounts []snapshotcreator.AccountDetails + accounts := make([]snapshotcreator.AccountDetails, 0, len(configYaml.Validators)+len(configYaml.BlockIssuers)) for _, validator := range configYaml.Validators { pubkey := validator.PublicKey fmt.Printf("adding validator %s with publicKey %s\n", validator.Name, pubkey) @@ -80,7 +80,7 @@ func GenerateFromYaml(hostsFile string) ([]options.Option[snapshotcreator.Option accounts = append(accounts, account) } - var basicOutputs []snapshotcreator.BasicOutputDetails + basicOutputs := make([]snapshotcreator.BasicOutputDetails, 0, len(configYaml.BasicOutputs)) for _, basicOutput := range configYaml.BasicOutputs { address := lo.Return2(iotago.ParseBech32(basicOutput.Address)) amount := basicOutput.Amount