Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added default validator pubkey #92

Merged
merged 3 commits into from
Nov 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/genesis.go
Original file line number Diff line number Diff line change
@@ -173,9 +173,9 @@ func PlasmaAppGenStateJSON(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTx
return
}

func NewDefaultGenesisState() GenesisState {
func NewDefaultGenesisState(pubkey crypto.PubKey) GenesisState {
return GenesisState{
Validator: GenesisValidator{},
Validator: GenesisValidator{pubkey, ""},
UTXOs: nil,
}
}
5 changes: 4 additions & 1 deletion client/plasmad/cmd/init.go
Original file line number Diff line number Diff line change
@@ -64,13 +64,15 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob
if viper.GetString(flagMoniker) != "" {
config.Moniker = viper.GetString(flagMoniker)
}
valPubKey := ReadOrCreatePrivValidator(config.PrivValidatorFile())

var appState json.RawMessage
genFile := config.GenesisFile()
if appState, err = initializeEmptyGenesis(cdc, genFile, chainID,
if appState, err = initializeEmptyGenesis(cdc, genFile, chainID, valPubKey,
viper.GetBool(flagOverwrite)); err != nil {
return err
}

if err = ExportGenesisFile(genFile, chainID, nil, appState); err != nil {
return err
}
@@ -84,6 +86,7 @@ func InitCmd(ctx *server.Context, cdc *codec.Codec, appInit server.AppInit) *cob

cfg.WriteConfigFile(filepath.Join(config.RootDir, "config", "config.toml"), config)

fmt.Printf("Add an ethereum address to 'fee_address' to collect fees as a validator\n\n")
return displayInfo(cdc, toPrint)
},
}
4 changes: 2 additions & 2 deletions client/plasmad/cmd/utils.go
Original file line number Diff line number Diff line change
@@ -102,12 +102,12 @@ func loadGenesisDoc(cdc *amino.Codec, genFile string) (genDoc types.GenesisDoc,
}

func initializeEmptyGenesis(
cdc *codec.Codec, genFile, chainID string, overwrite bool,
cdc *codec.Codec, genFile, chainID string, pubkey crypto.PubKey, overwrite bool,
) (appState json.RawMessage, err error) {

if !overwrite && common.FileExists(genFile) {
return nil, fmt.Errorf("genesis.json file already exists: %v", genFile)
}

return codec.MarshalJSONIndent(cdc, app.NewDefaultGenesisState())
return codec.MarshalJSONIndent(cdc, app.NewDefaultGenesisState(pubkey))
}