Merge PR #4767: Sort genesis JSON before printing

This commit is contained in:
Alexander Bezobchuk 2019-07-23 13:00:26 -04:00 committed by Jack Zampolin
parent 5c95591265
commit 2a27ebc9ab
3 changed files with 7 additions and 6 deletions

View File

@ -0,0 +1 @@
Sort state JSON during export and initialization

View File

@ -4,18 +4,17 @@ package server
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"io/ioutil"
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
) )
const ( const (
@ -81,7 +80,7 @@ func ExportCmd(ctx *Context, cdc *codec.Codec, appExporter AppExporter) *cobra.C
return err return err
} }
fmt.Println(string(encoded)) fmt.Println(string(sdk.MustSortJSON(encoded)))
return nil return nil
}, },
} }

View File

@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil"
) )
@ -51,8 +52,8 @@ func displayInfo(cdc *codec.Codec, info printInfo) error {
return err return err
} }
fmt.Fprintf(os.Stderr, "%s\n", string(out)) // nolint: errcheck _, err = fmt.Fprintf(os.Stderr, "%s\n", string(sdk.MustSortJSON(out)))
return nil return err
} }
// InitCmd returns a command that initializes all files needed for Tendermint // InitCmd returns a command that initializes all files needed for Tendermint