Merge PR #1142: Export validators to genesis

* Validator export skeleton
* Update export command, add tests, update CHANGELOG
* Rename exportAppState to exportAppStateAndTMValidators
This commit is contained in:
Christopher Goes
2018-06-06 18:38:13 +02:00
committed by GitHub
parent 5f409ce832
commit 3fbee11ccc
13 changed files with 105 additions and 22 deletions
+6 -5
View File
@@ -5,6 +5,7 @@ import (
"path/filepath"
abci "github.com/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
)
@@ -13,8 +14,8 @@ import (
// and other flags (?) to start
type AppCreator func(string, log.Logger) (abci.Application, error)
// AppExporter dumps all app state to JSON-serializable structure
type AppExporter func(home string, log log.Logger) (json.RawMessage, error)
// AppExporter dumps all app state to JSON-serializable structure and returns the current validator set
type AppExporter func(home string, log log.Logger) (json.RawMessage, []tmtypes.GenesisValidator, error)
// ConstructAppCreator returns an application generation function
func ConstructAppCreator(appFn func(log.Logger, dbm.DB) abci.Application, name string) AppCreator {
@@ -30,12 +31,12 @@ func ConstructAppCreator(appFn func(log.Logger, dbm.DB) abci.Application, name s
}
// ConstructAppExporter returns an application export function
func ConstructAppExporter(appFn func(log.Logger, dbm.DB) (json.RawMessage, error), name string) AppExporter {
return func(rootDir string, logger log.Logger) (json.RawMessage, error) {
func ConstructAppExporter(appFn func(log.Logger, dbm.DB) (json.RawMessage, []tmtypes.GenesisValidator, error), name string) AppExporter {
return func(rootDir string, logger log.Logger) (json.RawMessage, []tmtypes.GenesisValidator, error) {
dataDir := filepath.Join(rootDir, "data")
db, err := dbm.NewGoLevelDB(name, dataDir)
if err != nil {
return nil, err
return nil, nil, err
}
return appFn(logger, db)
}