Skip to content

Commit

Permalink
Merge pull request #177 from pegnet/develop
Browse files Browse the repository at this point in the history
Version 2.0.3
  • Loading branch information
StarNeit authored Feb 25, 2021
2 parents 97d2b91 + c8c3522 commit f2fc6d4
Show file tree
Hide file tree
Showing 6 changed files with 505 additions and 23 deletions.
25 changes: 24 additions & 1 deletion cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"os"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -53,7 +54,7 @@ func init() {
//tx.Flags()
rootCmd.AddCommand(tx)
rootCmd.AddCommand(conv)

rootCmd.AddCommand(resetDB)
}

var minerDistro = &cobra.Command{
Expand Down Expand Up @@ -575,6 +576,28 @@ var status = &cobra.Command{
},
}

var resetDB = &cobra.Command{
Use: "resetDB",
Short: "reset sql database for the pegnetd node",
PersistentPreRun: always,
PreRun: SoftReadConfig,
Run: func(cmd *cobra.Command, args []string) {
rawpath := viper.GetString(config.SqliteDBPath)
fmt.Println("Resetting database...", rawpath)
if runtime.GOOS == "windows" {
rawpath = strings.Replace(rawpath, "$HOME", "$USERPROFILE", -1)
}
path := os.ExpandEnv(rawpath)

err := os.Remove(path)
if err != nil {
fmt.Println("Resetting database is failed. Manual removing is required.", err)
} else {
fmt.Println("Database has been reset successfully.")
}
},
}

func getProperties() srv.PegnetdProperties {
cl := srv.NewClient()
cl.PegnetdServer = viper.GetString(config.Pegnetd)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/AdamSLevy/jsonrpc2/v13 v13.0.1
github.com/Factom-Asset-Tokens/factom v0.0.0-20191114224337-71de98ff5b3e
github.com/mattn/go-sqlite3 v1.11.0
github.com/pegnet/pegnet v0.5.1-0.20201201194922-e59c2d3b3061
github.com/pegnet/pegnet v0.5.1-0.20210225213341-a476b4b2cc0f
github.com/rs/cors v1.7.0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5
Expand Down
Loading

0 comments on commit f2fc6d4

Please sign in to comment.