diff --git a/README.md b/README.md index b379d23a..d5080421 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ go build ## Example command To run blockbook with fast synchronization, connection to ZeroMQ and providing https and socket.io interface, with database in local directory *data* and connected to local bitcoind with configuration specified by parameter *-blockchaincfg*: ``` -./blockbook -sync -blockchaincfg=configs/bitcoin_testnet.json -internal=127.0.0.1:8333 -public=127.0.01:8334 -certfile=server/testcert -logtostderr +./blockbook -sync -blockchaincfg=configs/bitcoin_testnet.json -internal=127.0.0.1:8333 -public=127.0.0.1:8334 -certfile=server/testcert -logtostderr ``` Blockbook logs to stderr *-logtostderr* or to directory specified by parameter *-log_dir* . Verbosity of logs can be tuned by command line parameters *-v* and *-vmodule*, details at https://godoc.org/github.com/golang/glog diff --git a/db/rocksdb.go b/db/rocksdb.go index 37b0c085..30285dab 100644 --- a/db/rocksdb.go +++ b/db/rocksdb.go @@ -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 const refreshIterator = 5000000 const packedHeightBytes = 4 +const dbVersion = 0 // RepairRocksDB calls RocksDb db repair function func RepairRocksDB(name string) error { @@ -928,9 +929,13 @@ func (d *RocksDB) LoadInternalState(rpcCoin string) (*common.InternalState, erro nc := make([]common.InternalStateColumn, len(cfNames)) for i := 0; i < len(nc); i++ { nc[i].Name = cfNames[i] + nc[i].Version = dbVersion for j := 0; j < len(sc); j++ { 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].KeyBytes = sc[j].KeyBytes nc[i].ValueBytes = sc[j].ValueBytes