Merge pull request #986 from cosmos/adrian/sort_gentxs
Sort all genesis transaction by node id
This commit is contained in:
commit
9f3444d910
|
@ -66,8 +66,9 @@ func GaiaAppInit() server.AppInit {
|
||||||
|
|
||||||
fsAppGenTx := pflag.NewFlagSet("", pflag.ContinueOnError)
|
fsAppGenTx := pflag.NewFlagSet("", pflag.ContinueOnError)
|
||||||
fsAppGenTx.String(flagName, "", "validator moniker, if left blank, do not add validator")
|
fsAppGenTx.String(flagName, "", "validator moniker, if left blank, do not add validator")
|
||||||
fsAppGenTx.String(flagClientHome, DefaultCLIHome, "home directory for the client, used for key generation")
|
fsAppGenTx.String(flagClientHome, DefaultCLIHome,
|
||||||
fsAppGenTx.Bool(flagOWK, false, "overwrite the for the accounts created")
|
"home directory for the client, used for key generation")
|
||||||
|
fsAppGenTx.Bool(flagOWK, false, "overwrite the accounts created")
|
||||||
|
|
||||||
return server.AppInit{
|
return server.AppInit{
|
||||||
FlagsAppGenState: fsAppGenState,
|
FlagsAppGenState: fsAppGenState,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -210,16 +211,18 @@ func InitCmd(ctx *Context, cdc *wire.Codec, appInit AppInit) *cobra.Command {
|
||||||
func processGenTxs(genTxsDir string, cdc *wire.Codec, appInit AppInit) (
|
func processGenTxs(genTxsDir string, cdc *wire.Codec, appInit AppInit) (
|
||||||
validators []tmtypes.GenesisValidator, appGenTxs []json.RawMessage, persistentPeers string, err error) {
|
validators []tmtypes.GenesisValidator, appGenTxs []json.RawMessage, persistentPeers string, err error) {
|
||||||
|
|
||||||
// XXX sort the files by contents just incase people renamed their files
|
|
||||||
var fos []os.FileInfo
|
var fos []os.FileInfo
|
||||||
fos, err = ioutil.ReadDir(genTxsDir)
|
fos, err = ioutil.ReadDir(genTxsDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
genTxs := make(map[string]GenesisTx)
|
||||||
|
var nodeIDs []string
|
||||||
for _, fo := range fos {
|
for _, fo := range fos {
|
||||||
filename := path.Join(genTxsDir, fo.Name())
|
filename := path.Join(genTxsDir, fo.Name())
|
||||||
if !fo.IsDir() && (path.Ext(filename) != ".json") {
|
if !fo.IsDir() && (path.Ext(filename) != ".json") {
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the genTx
|
// get the genTx
|
||||||
|
@ -234,6 +237,15 @@ func processGenTxs(genTxsDir string, cdc *wire.Codec, appInit AppInit) (
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
genTxs[genTx.NodeID] = genTx
|
||||||
|
nodeIDs = append(nodeIDs, genTx.NodeID)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Strings(nodeIDs)
|
||||||
|
|
||||||
|
for _, nodeID := range nodeIDs {
|
||||||
|
genTx := genTxs[nodeID]
|
||||||
|
|
||||||
// combine some stuff
|
// combine some stuff
|
||||||
validators = append(validators, genTx.Validator)
|
validators = append(validators, genTx.Validator)
|
||||||
appGenTxs = append(appGenTxs, genTx.AppGenTx)
|
appGenTxs = append(appGenTxs, genTx.AppGenTx)
|
||||||
|
|
Loading…
Reference in New Issue