From 75f01c16922fa0e776e01b22102915d48220f68b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 29 Nov 2016 21:43:20 -0800 Subject: [PATCH] migrate: check tip index for chaindbv2. --- migrate/chaindb1to2.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/migrate/chaindb1to2.js b/migrate/chaindb1to2.js index f71997c0..b3c15713 100644 --- a/migrate/chaindb1to2.js +++ b/migrate/chaindb1to2.js @@ -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();