Skip to content

Commit

Permalink
cmd/node: recover setting conf.Vochain.Network
Browse files Browse the repository at this point in the history
An earlier commit removed that line as I thought it was unnecessary.
I missed that "chain" isn't bound to Vochain.Network,
because the flag name isn't in the "vochainNetwork" format to match.

Add it back with enough docs so that we know why it's needed,
and improve the error so it isn't confusing on empty strings:

    cannot find a valid genesis for the  network
  • Loading branch information
mvdan authored and p4u committed Dec 22, 2023
1 parent e636621 commit fa8a3fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ func loadConfig() *config.Config {
if err != nil {
log.Fatalf("cannot unmarshal loaded config file: %s", err)
}
// Note that conf.Vochain.Indexer isn't bound with viper.
// Note that these Config.Vochain fields aren't bound via viper.
// We could do that if we rename the flags, e.g. vochainIndexerArchiveURL.
conf.Vochain.Indexer.ArchiveURL = viper.GetString("archiveURL")
conf.Vochain.Network = viper.GetString("chain")

if conf.SigningKey == "" {
log.Info("no signing key, generating one...")
Expand Down
2 changes: 1 addition & 1 deletion service/vochain.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (vs *VocdoniService) Vochain() error {
return err
}
if _, ok := vocdoniGenesis.Genesis[vs.Config.Network]; !ok {
err = fmt.Errorf("cannot find a valid genesis for the %s network", vs.Config.Network)
err = fmt.Errorf("cannot find a valid genesis for the %q network", vs.Config.Network)
return err
}
genesisBytes = vocdoniGenesis.Genesis[vs.Config.Network].Genesis.Marshal()
Expand Down

0 comments on commit fa8a3fe

Please sign in to comment.