prysm-pulse/beacon-chain/node/clear_db.go
Raul Jordan d9c0e65cef
Improve Beacon Node Logging UX (#3600)
* info logs beacon node improvements

* prom test fixes

* info logging changes

* wrapped up node info logging

* changed to debug level

* warn logs taken care of

* Terence suggestion

* warn spacing

* better logging in initial sync

* debug level standardized

* complete debug standardization

* participation at epoch end

* fix archive tests

* even more test fixes

* prom test

* ops test

* powtest

* rpc sync test

* rem part

* log formatting
2019-10-01 15:05:17 -05:00

54 lines
1.1 KiB
Go

package node
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
)
func confirmDelete(d db.Database, path string) (db.Database, error) {
var clearDB bool
var err error
reader := bufio.NewReader(os.Stdin)
log.Warn("This will delete all the chain data stored in your data directory - " +
"do you want to proceed? (Y/N)")
for {
fmt.Print(">> ")
line, _, err := reader.ReadLine()
if err != nil {
return nil, err
}
trimmedLine := strings.TrimSpace(string(line))
lineInput := strings.ToUpper(trimmedLine)
if lineInput != "Y" && lineInput != "N" {
log.Errorf("Invalid option of %s chosen, enter Y/N", line)
continue
}
if lineInput == "Y" {
log.Warn("Deleting all chain data from data directory")
clearDB = true
break
}
log.Info("Not deleting chain data, the db will be initialized" +
" with the current data directory.")
break
}
if clearDB {
if err := d.ClearDB(); err != nil {
return nil, err
}
d, err = db.NewDB(path)
if err != nil {
return nil, err
}
}
return d, nil
}