Rollback to given height
parent
2dd0b9fc21
commit
858f196484
21
blockbook.go
21
blockbook.go
|
@ -42,8 +42,9 @@ var (
|
||||||
|
|
||||||
dbPath = flag.String("path", "./data", "path to address index directory")
|
dbPath = flag.String("path", "./data", "path to address index directory")
|
||||||
|
|
||||||
blockHeight = flag.Int("blockheight", -1, "height of the starting block")
|
blockHeight = flag.Int("blockheight", -1, "height of the starting block")
|
||||||
blockUntil = flag.Int("blockuntil", -1, "height of the final block")
|
blockUntil = flag.Int("blockuntil", -1, "height of the final block")
|
||||||
|
rollbackHeight = flag.Int("rollback", -1, "rollback to the given height and quit")
|
||||||
|
|
||||||
queryAddress = flag.String("address", "", "query contents of this address")
|
queryAddress = flag.String("address", "", "query contents of this address")
|
||||||
|
|
||||||
|
@ -93,6 +94,22 @@ func main() {
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
if *rollbackHeight >= 0 {
|
||||||
|
bestHeight, _, err := db.GetBestBlock()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("rollbackHeight: %v", err)
|
||||||
|
}
|
||||||
|
if uint32(*rollbackHeight) > bestHeight {
|
||||||
|
log.Printf("nothing to rollback, rollbackHeight %d, bestHeight: %d", *rollbackHeight, bestHeight)
|
||||||
|
} else {
|
||||||
|
err = db.DisconnectBlocks(uint32(*rollbackHeight), bestHeight)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("rollbackHeight: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if *resync {
|
if *resync {
|
||||||
if err := resyncIndex(rpc, db); err != nil {
|
if err := resyncIndex(rpc, db); err != nil {
|
||||||
log.Fatalf("resyncIndex %v", err)
|
log.Fatalf("resyncIndex %v", err)
|
||||||
|
|
Loading…
Reference in New Issue