Merge pull request #118 from matiu/bug/updagreScript

fixes in upgradev2 script
This commit is contained in:
Gustavo Maximiliano Cortez 2014-06-04 12:14:39 -03:00
commit 5b7df7cd9c
2 changed files with 30 additions and 2 deletions

View File

@ -393,10 +393,38 @@ BlockDb.prototype._runScript = function(script, cb) {
BlockDb.prototype.migrateV02 = function(cb) {
var k = 'txb-';
var dbScript = [];
var c=0;
var c2=0;
var N=50000;
this.txDb._db.createReadStream({
start: 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) {

View File

@ -711,7 +711,7 @@ TransactionDb.prototype.migrateV02 = function(cb) {
value: v[0],
});
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 () {
c=0;
dbScript=[];