migrate: chaindb2to3 fixes.
This commit is contained in:
parent
b6e6442026
commit
517a66309c
@ -70,7 +70,7 @@ async function readJournal() {
|
||||
state = data.readUInt8(1, true);
|
||||
hash = data.toString('hex', 2, 34);
|
||||
|
||||
console.log('Read journal.');
|
||||
console.log('Reading journal.');
|
||||
console.log('Recovering from state %d.', state);
|
||||
|
||||
return [state, hash];
|
||||
@ -117,14 +117,17 @@ async function reserializeUndo(hash) {
|
||||
if (hash !== encoding.NULL_HASH)
|
||||
tip = await getEntry(hash);
|
||||
|
||||
console.log('Reserializing undo coins from tip %s.', tip.rhash());
|
||||
console.log('Reserializing undo coins from tip %s.', util.revHex(tip.hash));
|
||||
|
||||
while (tip.height !== 0) {
|
||||
let undoData = await db.get(pair('u', tip.hash));
|
||||
let blockData = await db.get(pair('b', tip.hash));
|
||||
let block, old, undo;
|
||||
|
||||
assert(undoData);
|
||||
if (!undoData) {
|
||||
tip = await getEntry(tip.prevBlock);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!blockData) {
|
||||
if (!(await isPruned()))
|
||||
@ -154,7 +157,7 @@ async function reserializeUndo(hash) {
|
||||
item.coinbase = coin.coinbase;
|
||||
item.output.script = output.script;
|
||||
item.output.value = output.value;
|
||||
item.spent = false;
|
||||
item.spent = true;
|
||||
item.raw = null;
|
||||
|
||||
// Store an index of heights and versions for later.
|
||||
@ -231,7 +234,7 @@ async function cleanupIndex() {
|
||||
|
||||
async function reserializeCoins(hash) {
|
||||
let batch = db.batch();
|
||||
let start = false;
|
||||
let start = true;
|
||||
let total = 0;
|
||||
|
||||
let iter = db.iterator({
|
||||
@ -539,6 +542,6 @@ function bpair(prefix, hash, index) {
|
||||
|
||||
console.log('Migration complete.');
|
||||
process.exit(0);
|
||||
}).catch((err) => {
|
||||
})().catch((err) => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
@ -13,7 +13,7 @@ const Output = require('../../lib/primitives/output');
|
||||
const BufferReader = require('../../lib/utils/reader');
|
||||
const StaticWriter = require('../../lib/utils/staticwriter');
|
||||
const encoding = require('../../lib/utils/encoding');
|
||||
const compressor = require('../../lib/coins/compress');
|
||||
const compressor = require('./compress');
|
||||
const compress = compressor.compress;
|
||||
const decompress = compressor.decompress;
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const Coins = require('../../lib/coins/coins');
|
||||
const UndoCoins = require('../../lib/coins/undocoins');
|
||||
const Coins = require('./coins');
|
||||
const UndoCoins = require('./undocoins');
|
||||
const BufferReader = require('../../lib/utils/reader');
|
||||
const BufferWriter = require('../../lib/utils/writer');
|
||||
const CoinEntry = Coins.CoinEntry;
|
||||
|
||||
@ -11,8 +11,8 @@ const BufferReader = require('../../lib/utils/reader');
|
||||
const StaticWriter = require('../../lib/utils/staticwriter');
|
||||
const encoding = require('../../lib/utils/encoding');
|
||||
const Output = require('../../lib/primitives/output');
|
||||
const Coins = require('../../lib/coins');
|
||||
const compressor = require('../../lib/compress');
|
||||
const Coins = require('./coins');
|
||||
const compressor = require('./compress');
|
||||
const compress = compressor.compress;
|
||||
const decompress = compressor.decompress;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user