remove dev-util and util legacy code
This commit is contained in:
parent
c25be8eef2
commit
de8a489fab
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var
|
||||
config = require('../config/config'),
|
||||
levelup = require('levelup');
|
||||
|
||||
|
||||
db = levelup(config.leveldb + '/blocks');
|
||||
|
||||
db.createReadStream({start: 'b-'})
|
||||
.on('data', function (data) {
|
||||
console.log('[block-level.js.11:data:]',data); //TODO
|
||||
if (data==false) c++;
|
||||
})
|
||||
.on('error', function (err) {
|
||||
return cb(err);
|
||||
})
|
||||
.on('close', function () {
|
||||
return cb(null);
|
||||
})
|
||||
.on('end', function () {
|
||||
return cb(null);
|
||||
});
|
||||
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var levelup = require('levelup');
|
||||
|
||||
|
||||
|
||||
var dbPath = process.argv[2];
|
||||
var s = process.argv[3];
|
||||
console.log('DB: ',dbPath); //TODO
|
||||
|
||||
|
||||
|
||||
var db = levelup(dbPath );
|
||||
|
||||
|
||||
db.createReadStream({start: s, end: s+'~'})
|
||||
.on('data', function (data) {
|
||||
console.log(data.key + ' => ' + data.value); //TODO
|
||||
})
|
||||
.on('error', function () {
|
||||
})
|
||||
.on('end', function () {
|
||||
});
|
||||
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var mongoose= require('mongoose'),
|
||||
config = require('../config/config');
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var T = require('../app/models/TransactionOut');
|
||||
|
||||
|
||||
// var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
||||
var hash = process.argv[2] || '6749762ae220c10705556799dcec9bb6a54a7b881eb4b961323a3363b00db518';
|
||||
|
||||
|
||||
|
||||
|
||||
mongoose.connect(config.db);
|
||||
|
||||
mongoose.connection.on('error', function(err) { console.log(err); });
|
||||
|
||||
|
||||
mongoose.connection.on('open', function() {
|
||||
|
||||
var b = new Buffer(hash,'hex');
|
||||
|
||||
T.createFromTxs([hash], function(err, ret) {
|
||||
|
||||
console.log('Err:');
|
||||
console.log(err);
|
||||
|
||||
|
||||
console.log('Ret:');
|
||||
console.log(util.inspect(ret,{depth:null}));
|
||||
mongoose.connection.close();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
FIND='find';
|
||||
|
||||
##if [[ "$OSTYPE" =~ "darwin" ]]
|
||||
##then
|
||||
## FIND='gfind'
|
||||
##fi
|
||||
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "$0 : find functions references "
|
||||
echo "Usage $0 function_name "
|
||||
exit;
|
||||
fi
|
||||
|
||||
EXTRA=''
|
||||
|
||||
|
||||
CMD="grep -rnH"
|
||||
|
||||
if [ "$2" != '--nocolor' ]
|
||||
then
|
||||
CMD="$CMD --color=always"
|
||||
fi
|
||||
|
||||
|
||||
$FIND -L . -name \*.json -not -wholename \*node_modules\* -not -wholename \*public/lib\* -exec $CMD "$1" {} + \
|
||||
-o -name \*.html -not -wholename \*node_modules\* -not -wholename \*public/lib\* -exec $CMD "$1" {} + \
|
||||
-o -name \*.jade -not -wholename \*node_modules\* -not -wholename \*public/lib\* -exec $CMD "$1" {} + \
|
||||
-o -name \*.js -not -wholename \*node_modules\* -not -wholename \*public/lib\* -exec $CMD "$1" {} +
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var util = require('util'),
|
||||
config = require('../config/config');
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var A = require('../app/models/Address');
|
||||
|
||||
// var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
||||
var hash = process.argv[2] || 'mp3Rzxx9s1A21SY3sjJ3CQoa2Xjph7e5eS';
|
||||
|
||||
var a= new A(hash);
|
||||
a.update(function(err) {
|
||||
console.log('Err:');
|
||||
console.log(err);
|
||||
|
||||
console.log('Ret:');
|
||||
console.log(util.inspect(a,{depth:null}));
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var util = require('util'),
|
||||
config = require('../config/config');
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var TransactionDb = require('../lib/TransactionDb.js').default();
|
||||
var hash = process.argv[2] || '4286d6fc82a314348af4e9d3ce649f78ce4569937e9ad6613563755f0d14e3d1';
|
||||
|
||||
var t= TransactionDb.fromIdWithInfo(hash,function(err,tx) {
|
||||
console.log('Err:');
|
||||
console.log(err);
|
||||
|
||||
console.log('Ret:');
|
||||
console.log(util.inspect(tx,{depth:null}));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var RpcClient = require('../node_modules/bitcore/RpcClient');
|
||||
|
||||
var config = require('../config/config');
|
||||
|
||||
|
||||
var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
||||
//var hash = process.argv[2] || 'f6c2901f39fd07f2f2e503183d76f73ecc1aee9ac9216fde58e867bc29ce674e';
|
||||
|
||||
//hash = 'e2253359458db3e732c82a43fc62f56979ff59928f25a2df34dfa443e9a41160';
|
||||
|
||||
var rpc = new RpcClient(config.bitcoind);
|
||||
|
||||
rpc.getBlock( hash, function(err, ret) {
|
||||
|
||||
console.log('Err:');
|
||||
console.log(err);
|
||||
|
||||
|
||||
console.log('Ret:');
|
||||
console.log(util.inspect(ret, { depth: 10} ));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var config = require('../config/config'),
|
||||
levelup = require('levelup');
|
||||
|
||||
|
||||
|
||||
var k = process.argv[2];
|
||||
var v = process.argv[3];
|
||||
var isBlock = process.argv[4] === '1';
|
||||
|
||||
|
||||
var dbPath = config.leveldb + (isBlock ? '/blocks' : '/txs');
|
||||
console.log('DB: ',dbPath); //TODO
|
||||
|
||||
|
||||
|
||||
var db = levelup(dbPath );
|
||||
|
||||
|
||||
if (v) {
|
||||
db.put(k,v,function(err) {
|
||||
console.log('[PUT done]',err); //TODO
|
||||
});
|
||||
}
|
||||
else {
|
||||
db.del(k,function(err) {
|
||||
console.log('[DEL done]',err); //TODO
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var config = require('../config/config'),
|
||||
levelup = require('levelup');
|
||||
|
||||
|
||||
|
||||
var s = process.argv[2];
|
||||
var isBlock = process.argv[3] === '1';
|
||||
|
||||
|
||||
var dbPath = config.leveldb + (isBlock ? '/blocks' : '/txs');
|
||||
console.log('DB: ',dbPath); //TODO
|
||||
|
||||
|
||||
|
||||
var db = levelup(dbPath );
|
||||
|
||||
|
||||
db.createReadStream({start: s, end: s+'~'})
|
||||
.on('data', function (data) {
|
||||
console.log(data.key + ' => ' + data.value); //TODO
|
||||
})
|
||||
.on('error', function () {
|
||||
})
|
||||
.on('end', function () {
|
||||
});
|
||||
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var assert = require('assert'),
|
||||
config = require('../config/config'),
|
||||
BlockExtractor = require('../lib/BlockExtractor').class(),
|
||||
networks = require('bitcore/networks'),
|
||||
util = require('bitcore/util/util');
|
||||
|
||||
var be = new BlockExtractor(config.bitcoind.dataDir, config.network);
|
||||
var network = config.network === 'testnet' ? networks.testnet: networks.livenet;
|
||||
// console.log('[read_block.js.13]', be.nextFile() );
|
||||
|
||||
var c=0;
|
||||
while (c++ < 100) {
|
||||
be.getNextBlock(function(err, b) {
|
||||
console.log('[read_block.js.14]',err, c, b?util.formatHashAlt(b.hash):''); //TODO
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
|
||||
|
||||
first 5%
|
||||
|
||||
=> with data + mongo + w/RPC for blocks: 48.8s
|
||||
=> with RPC + mongo: 2m26s
|
||||
=> with files + mongo + wo/RPC for blocks: 36.7s
|
||||
=> with files + mongo + wo/RPC for blocks + wo/mongoIndexes:
|
||||
|
||||
|
||||
first 10%
|
||||
|
||||
=> sin RPC, sin Tx, sin store block => 0.7s
|
||||
=> sin RPC, sin grabar, procesando TX => 8.5s
|
||||
=> sin RPC, sin TX processing, sin grabar => 12s28
|
||||
=> con RPC, TX processing, sin Grabar Tx, grabando bloques => 29s
|
||||
=> con RPC, sin TX processing, sin Grabar Tx, grabando bloques => 35s
|
||||
=> con RPC, TX processing, sin Grabar Tx, grabando bloques => 43s
|
||||
|
||||
=> TX processing, sin RPC, sin saves TX, y blocks => 11.6s
|
||||
=> TX processing, CON RPC, sin saves TX, y blocks => 35s
|
||||
=> con RPC, TX processing, sin saves TX => 45s
|
||||
=> con RPC, TX processing, Grabarndo todo => 78s
|
||||
=> con RPC, TX processing, Grabarndo todo => 78s
|
||||
(18k blocks, 36k txouts)
|
||||
|
||||
//LEVEL DB
|
||||
=> sin RPC, TX processing, todo en level => 14s
|
||||
=> con RPC, TX processing, todo en level => 39.7s
|
||||
=> con RPC, TX processing, tx mongo, blocks en level => 64s
|
||||
|
||||
|
||||
=> sin RPC, TX processing, todo en level, handling REORGs, more data => 28s
|
||||
=> sin RPC, TX processing, todo en level, handling REORGs, more data, tx ts => 34t s
|
||||
|
||||
|
||||
//FROM blk00002.dat (more txs), 5%
|
||||
|
||||
=> now total : 1m13s
|
||||
=> removing block writes => 1m8s
|
||||
=> sacando los contenidos adentro de getblock from file de => 4.5s!!
|
||||
|
||||
=> con base58 cpp => 21s
|
||||
=> toda la testnet => 17m !!
|
||||
|
||||
10% de blk2
|
||||
=> 50s con base58cpp
|
||||
=> 41s commentando todo addr
|
||||
=> 5s commentando todo get HistoricSync.prototype.getBlockFromFile = function(cb) {
|
||||
=> 15s commentando todo get HistoricSync.prototype.getBlockFromFile = function(cb) {
|
||||
|
||||
10% de blk 1
|
||||
=> 59s
|
||||
=> 15s comentando desde b.getStandardizedObject()
|
||||
=> 39s comentando dps b.getStandardizedObject()
|
||||
|
||||
|
||||
Mon Mar 10 11:59:25 ART 2014
|
||||
10% de blk 0 (testnet)
|
||||
=> 37s
|
||||
|
||||
Thu May 22 13:42:50 ART 2014 (base58check + toString opts + custom getStandardizedObject)
|
||||
10% testnet
|
||||
=> 29s
|
||||
|
||||
|
||||
100% testnet
|
||||
=> 17m10s
|
||||
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var RpcClient = require('../node_modules/bitcore/RpcClient').class();
|
||||
|
||||
var config = require('../config/config');
|
||||
|
||||
var rpc = new RpcClient(config.bitcoind);
|
||||
|
||||
var block = rpc.getInfo(function(err, block) {
|
||||
if (err) {
|
||||
console.log("Err:");
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
console.log("Block info:");
|
||||
console.log(block);
|
||||
});
|
||||
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var Sync = require('../lib/Sync').class();
|
||||
|
||||
|
||||
var s = new Sync();
|
||||
|
||||
|
||||
s.setOrphan(
|
||||
'0000000000c2b1e8dab92a72741289e5ef0d4f375fd1b26f729da2ba979c028a',
|
||||
'000000000228f9d02654459e09998c7557afa9082784c11226853f5feb805df9',
|
||||
function (err) {
|
||||
console.log('[sync-level.js.15]',err); //TODO
|
||||
});
|
||||
|
||||
|
||||
18
util/p2p.js
18
util/p2p.js
@ -1,18 +0,0 @@
|
||||
#! /usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var PeerSync = require('../lib/PeerSync');
|
||||
|
||||
var PROGRAM_VERSION = '0.1';
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version(PROGRAM_VERSION)
|
||||
.parse(process.argv);
|
||||
|
||||
var ps = new PeerSync();
|
||||
ps.run();
|
||||
|
||||
|
||||
49
util/sync.js
49
util/sync.js
@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var SYNC_VERSION = '0.1';
|
||||
var program = require('commander');
|
||||
var HistoricSync = require('../lib/HistoricSync');
|
||||
var async = require('async');
|
||||
|
||||
program
|
||||
.version(SYNC_VERSION)
|
||||
.option('-D --destroy', 'Remove current DB (and start from there)', 0)
|
||||
.option('-S --startfile', 'Number of file from bitcoind to start(default=0)')
|
||||
.option('-R --rpc', 'Force sync with RPC')
|
||||
.option('--start [hash]', 'StartAt block')
|
||||
.option('--stop [hash]', 'StopAt block')
|
||||
.option('-v --verbose', 'Verbose 0/1', 0)
|
||||
.parse(process.argv);
|
||||
|
||||
var historicSync = new HistoricSync({
|
||||
shouldBroadcastSync: true,
|
||||
});
|
||||
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
if (!program.destroy) return cb();
|
||||
console.log('Deleting Sync DB...');
|
||||
historicSync.sync.destroy(cb);
|
||||
},
|
||||
function(cb) {
|
||||
var opts= {
|
||||
forceStartFile: program.startfile,
|
||||
forceRPC: program.rpc,
|
||||
startAt: program.start,
|
||||
stopAt: program.stop,
|
||||
};
|
||||
console.log('[options]',opts); //TODO
|
||||
historicSync.start(opts,cb);
|
||||
},
|
||||
],
|
||||
function(err) {
|
||||
historicSync.close();
|
||||
if (err) console.log('CRITICAL ERROR: ', historicSync.info());
|
||||
});
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var HistoricSync = require('../lib/HistoricSync');
|
||||
var async = require('async');
|
||||
|
||||
|
||||
var historicSync = new HistoricSync({ shouldBroadcastSync: false });
|
||||
var txDb=historicSync.sync.txDb;
|
||||
var bDb=historicSync.sync.bDb;
|
||||
|
||||
var height = 0;
|
||||
var hash = historicSync.genesis;
|
||||
var tipHash;
|
||||
|
||||
async.series([
|
||||
function(c){
|
||||
txDb.checkVersion02(function(isV2){
|
||||
var err;
|
||||
if(isV2) err='Already in v0.2!';
|
||||
return c(err);
|
||||
});
|
||||
},
|
||||
function(c){
|
||||
console.log('[1/3] Migrating txs ... (this will take some minutes...)'); //TODO
|
||||
txDb.migrateV02(c);
|
||||
},
|
||||
function(c){
|
||||
var script=[];
|
||||
async.whilst(
|
||||
function() {
|
||||
return hash;
|
||||
},
|
||||
function (w_cb) {
|
||||
script=script.concat(bDb._setHeightScript(hash,height));
|
||||
bDb.getNext(hash,function(err,val){
|
||||
if (err) return w_cb(err);
|
||||
tipHash = hash;
|
||||
hash = val;
|
||||
if (hash) height++;
|
||||
if (!(height%1000) || !hash) {
|
||||
console.log('[2/3] migrating blocks \t%d blocks processed', height);
|
||||
bDb._runScript(script, function(err) {
|
||||
script=[];
|
||||
return w_cb(err);
|
||||
});
|
||||
}
|
||||
else return w_cb();
|
||||
});
|
||||
}, c);
|
||||
},
|
||||
function(c){
|
||||
console.log('[3/3] Migrating txs... (this will take some minutes...)'); //TODO
|
||||
bDb.migrateV02(c);
|
||||
},
|
||||
function(c){
|
||||
bDb.setTip(tipHash, height, c);
|
||||
},
|
||||
function(c){
|
||||
bDb.migrateV02cleanup(c);
|
||||
},
|
||||
],function(err){
|
||||
if (err)
|
||||
console.log('## '+err);
|
||||
else
|
||||
console.log('Finished OK.');
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user