mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-28 14:17:17 +00:00
49e0ddf861
* use LRU cache on skip slots * add a metric * gaz * more metrics * temporary log * added more logging * fix * only update, if its higher than the cache * only update, if its higher than the cache * increase the cache size, just in case * split cache related stuff into its own file * add feature flag * clean up * add new test * make test proper * godoc * preston's review
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package node
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
|
)
|
|
|
|
func confirmDelete(d db.Database, path string, force bool) (db.Database, error) {
|
|
var clearDB bool
|
|
var err error
|
|
reader := bufio.NewReader(os.Stdin)
|
|
if force {
|
|
clearDB = true
|
|
} else {
|
|
log.Warn("This will delete your beacon chain data base stored in your data directory. " +
|
|
"Your database backups will not be removed - 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" {
|
|
clearDB = true
|
|
break
|
|
}
|
|
log.Info("Not deleting chain database, the db will be initialized" +
|
|
" with the current data directory.")
|
|
break
|
|
}
|
|
}
|
|
|
|
if clearDB {
|
|
log.Warning("Removing database")
|
|
if err := d.ClearDB(); err != nil {
|
|
return nil, err
|
|
}
|
|
d, err = db.NewDB(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return d, nil
|
|
}
|