Merge pull request #118 from matiu/bug/updagreScript
fixes in upgradev2 script
This commit is contained in:
commit
5b7df7cd9c
@ -393,10 +393,38 @@ BlockDb.prototype._runScript = function(script, cb) {
|
|||||||
|
|
||||||
BlockDb.prototype.migrateV02 = function(cb) {
|
BlockDb.prototype.migrateV02 = function(cb) {
|
||||||
var k = 'txb-';
|
var k = 'txb-';
|
||||||
|
var dbScript = [];
|
||||||
|
var c=0;
|
||||||
|
var c2=0;
|
||||||
|
var N=50000;
|
||||||
this.txDb._db.createReadStream({
|
this.txDb._db.createReadStream({
|
||||||
start: k,
|
start: k,
|
||||||
end: k + '~'
|
end: k + '~'
|
||||||
}).pipe(db.createWriteStream()).on('close', cb);
|
})
|
||||||
|
.on('data', function(data) {
|
||||||
|
var k = data.key.split('-');
|
||||||
|
var v = data.value.split(':');
|
||||||
|
dbScript.push({
|
||||||
|
type: 'put',
|
||||||
|
key: IN_BLK_PREFIX + k[1],
|
||||||
|
value: data.value,
|
||||||
|
});
|
||||||
|
if (c++>N) {
|
||||||
|
console.log('\t%dM txs processed', ((c2+=N)/1e6).toFixed(3));
|
||||||
|
db.batch(dbScript,function () {
|
||||||
|
c=0;
|
||||||
|
dbScript=[];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('error', function(err) {
|
||||||
|
return cb(err);
|
||||||
|
})
|
||||||
|
.on('end', function (){
|
||||||
|
return cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BlockDb.prototype.migrateV02cleanup = function(cb) {
|
BlockDb.prototype.migrateV02cleanup = function(cb) {
|
||||||
|
|||||||
@ -711,7 +711,7 @@ TransactionDb.prototype.migrateV02 = function(cb) {
|
|||||||
value: v[0],
|
value: v[0],
|
||||||
});
|
});
|
||||||
if (c++>N) {
|
if (c++>N) {
|
||||||
console.log('\t%dM txs processed', ((c2+=N)/1e6).toFixed(3)); //TODO
|
console.log('\t%dM txs outs processed', ((c2+=N)/1e6).toFixed(3)); //TODO
|
||||||
db.batch(dbScript,function () {
|
db.batch(dbScript,function () {
|
||||||
c=0;
|
c=0;
|
||||||
dbScript=[];
|
dbScript=[];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user