Skip to content
Snippets Groups Projects
Unverified Commit 70cfe4ee authored by Acha Bill's avatar Acha Bill Committed by GitHub
Browse files

adds a cli to override database dirty flag (#629)

* adds a cli to override database dirty flag

* gofmt
parent bbd89929
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,12 @@ const (
CfgDatabaseDir = "database.directory"
// CfgDatabaseInMemory defines whether to use an in-memory database.
CfgDatabaseInMemory = "database.inMemory"
// CfgDatabaseDirty defines whether to override the database dirty flag.
CfgDatabaseDirty = "database.dirty"
)
func init() {
flag.String(CfgDatabaseDir, "mainnetdb", "path to the database folder")
flag.Bool(CfgDatabaseInMemory, false, "whether the database is only kept in memory and not persisted")
flag.String(CfgDatabaseDirty, "", "set the dirty flag of the database")
}
......@@ -3,6 +3,7 @@ package database
import (
"errors"
"strconv"
"sync"
"time"
......@@ -77,6 +78,17 @@ func configure(_ *node.Plugin) {
log.Fatalf("Failed to check database version: %s", err)
}
if str := config.Node().GetString(CfgDatabaseDirty); str != "" {
val, err := strconv.ParseBool(str)
if err != nil {
log.Warnf("Invalid %s: %s", CfgDatabaseDirty, err)
} else if val {
MarkDatabaseUnhealthy()
} else {
MarkDatabaseHealthy()
}
}
if IsDatabaseUnhealthy() {
log.Fatal("The database is marked as not properly shutdown/corrupted, please delete the database folder and restart.")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment