migrate: check tip index for chaindbv2.

This commit is contained in:
Christopher Jeffrey 2016-11-29 21:43:20 -08:00
parent 8b8e1e3f13
commit 75f01c1692
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -64,6 +64,26 @@ var updateVersion = co(function* updateVersion() {
batch.put('V', ver);
});
var checkTipIndex = co(function* checkTipIndex() {
var iter, item;
iter = db.iterator({
gte: pair('p', constants.ZERO_HASH),
lte: pair('p', constants.MAX_HASH)
});
item = yield iter.next();
if (!item) {
console.log('No tip index found.');
console.log('Please run migrate/ensure-tip-index.js first!');
process.exit(1);
return;
}
yield iter.end();
});
var updateOptions = co(function* updateOptions() {
if (yield db.has('O'))
return;
@ -202,6 +222,7 @@ co.spawn(function* () {
console.log('Opened %s.', file);
batch = db.batch();
yield updateVersion();
yield checkTipIndex();
yield updateOptions();
yield updateDeployments();
yield reserializeCoins();