Skip to content

Commit

Permalink
[ONT-894]Add cleartestmodedata flag in testmode (DNAProject#367)
Browse files Browse the repository at this point in the history
signed-off-by:[email protected]
  • Loading branch information
gasby88 authored and laizy committed Jun 19, 2018
1 parent 330a2d1 commit 08439e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ var AppHelpFlagGroups = []flagGroup{
Flags: []cli.Flag{
utils.EnableTestModeFlag,
utils.TestModeGenBlockTimeFlag,
utils.ClearTestModeDataFlag,
},
},
{
Expand Down
4 changes: 4 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ var (
Usage: "Interval of generate block in test mode, unit(s)",
Value: config.DEFAULT_GEN_BLOCK_TIME,
}
ClearTestModeDataFlag = cli.BoolFlag{
Name: "cleartestmodedata",
Usage: "Clear test mode block data",
}

//P2P setting
ReservedPeersOnlyFlag = cli.BoolFlag{
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func setupAPP() *cli.App {
//test mode setting
utils.EnableTestModeFlag,
utils.TestModeGenBlockTimeFlag,
utils.ClearTestModeDataFlag,
//rpc setting
utils.RPCDisabledFlag,
utils.RPCPortFlag,
Expand Down Expand Up @@ -234,7 +235,7 @@ func initLedger(ctx *cli.Context) (*ledger.Ledger, error) {
var err error
dbDir := config.DefConfig.Common.DataDir + string(os.PathSeparator) + config.DefConfig.P2PNode.NetworkName

if config.DefConfig.Genesis.ConsensusType == config.CONSENSUS_TYPE_SOLO {
if ctx.GlobalBool(utils.GetFlagName(utils.EnableTestModeFlag)) && ctx.GlobalBool(utils.GetFlagName(utils.ClearTestModeDataFlag)) {
err = os.RemoveAll(dbDir)
if err != nil {
log.Warnf("InitLedger remove:%s error:%s", dbDir, err)
Expand Down

0 comments on commit 08439e4

Please sign in to comment.