Check DB version on startup
This commit is contained in:
parent
df8342dc8d
commit
4db0895899
@ -21,6 +21,7 @@ import (
|
|||||||
// when doing huge scan, it is better to close it and reopen from time to time to free the resources
|
// when doing huge scan, it is better to close it and reopen from time to time to free the resources
|
||||||
const refreshIterator = 5000000
|
const refreshIterator = 5000000
|
||||||
const packedHeightBytes = 4
|
const packedHeightBytes = 4
|
||||||
|
const dbVersion = 0
|
||||||
|
|
||||||
// RepairRocksDB calls RocksDb db repair function
|
// RepairRocksDB calls RocksDb db repair function
|
||||||
func RepairRocksDB(name string) error {
|
func RepairRocksDB(name string) error {
|
||||||
@ -928,9 +929,13 @@ func (d *RocksDB) LoadInternalState(rpcCoin string) (*common.InternalState, erro
|
|||||||
nc := make([]common.InternalStateColumn, len(cfNames))
|
nc := make([]common.InternalStateColumn, len(cfNames))
|
||||||
for i := 0; i < len(nc); i++ {
|
for i := 0; i < len(nc); i++ {
|
||||||
nc[i].Name = cfNames[i]
|
nc[i].Name = cfNames[i]
|
||||||
|
nc[i].Version = dbVersion
|
||||||
for j := 0; j < len(sc); j++ {
|
for j := 0; j < len(sc); j++ {
|
||||||
if sc[j].Name == nc[i].Name {
|
if sc[j].Name == nc[i].Name {
|
||||||
nc[i].Version = sc[j].Version
|
// check the version of the column, if it does not match, the db is not compatible
|
||||||
|
if sc[j].Version != dbVersion {
|
||||||
|
return nil, errors.Errorf("DB version %v of column '%v' does not match the required version %v. DB is not compatible.", sc[j].Version, sc[j].Name, dbVersion)
|
||||||
|
}
|
||||||
nc[i].Rows = sc[j].Rows
|
nc[i].Rows = sc[j].Rows
|
||||||
nc[i].KeyBytes = sc[j].KeyBytes
|
nc[i].KeyBytes = sc[j].KeyBytes
|
||||||
nc[i].ValueBytes = sc[j].ValueBytes
|
nc[i].ValueBytes = sc[j].ValueBytes
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user