check network config
This commit is contained in:
parent
181c318f51
commit
abefb1a879
|
@ -35,9 +35,29 @@ function spec() {
|
|||
}
|
||||
|
||||
HistoricSync.prototype.init = function(opts, cb) {
|
||||
this.rpc = new RpcClient(config.bitcoind);
|
||||
this.opts = opts;
|
||||
this.sync.init(opts, cb);
|
||||
|
||||
var self = this;
|
||||
self.rpc = new RpcClient(config.bitcoind);
|
||||
self.opts = opts;
|
||||
self.sync.init(opts, function(err) {
|
||||
if (err) {
|
||||
self.err = err.message;
|
||||
self.syncInfo = util._extend(self.syncInfo, { error: err.message });
|
||||
return cb(err);
|
||||
}
|
||||
else {
|
||||
// check testnet?
|
||||
self.rpc.getBlockHash(0, function(err, res){
|
||||
if (!err && ( res && res.result !== self.genesis)) {
|
||||
self.err = 'Bad genesis block. Network mismatch between Insight and bitcoind? Insight is configured for:' + config.network;
|
||||
err = new Error(self.err);
|
||||
self.syncInfo = util._extend(self.syncInfo, { error: err.message });
|
||||
}
|
||||
return cb(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
HistoricSync.prototype.close = function() {
|
||||
|
|
|
@ -23,6 +23,12 @@ function($scope, $routeParams, $location, $rootScope, Global, Status, Sync, get_
|
|||
};
|
||||
|
||||
var on_sync_update = function(sync) {
|
||||
|
||||
if (sync.error) {
|
||||
$rootScope.syncError = sync.error;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sync.blocksToSync > sync.syncedBlocks) {
|
||||
var p = parseInt(100*(sync.syncedBlocks) / sync.blocksToSync);
|
||||
var delta = sync.blocksToSync - sync.syncedBlocks;
|
||||
|
|
|
@ -62,13 +62,19 @@ if (!config.disableHistoricSync) {
|
|||
shouldBroadcast: true,
|
||||
progressStep: 2,
|
||||
networkName: config.network
|
||||
}, function() {
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
var txt = 'ABORTED with error: ' + err.message;
|
||||
console.log('[historic_sync] ' + txt);
|
||||
}
|
||||
else {
|
||||
historicSync.smart_import(function(err){
|
||||
var txt= 'ended.';
|
||||
if (err) txt = 'ABORTED with error: ' + err.message;
|
||||
|
||||
console.log('[historic_sync] ' + txt, historicSync.syncInfo);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue