failover to RPC sync if File sync fails
This commit is contained in:
parent
67a68ee3ca
commit
f5d8891317
@ -19,6 +19,8 @@ module.exports.broadcastTx = function(tx) {
|
|||||||
if (ios) {
|
if (ios) {
|
||||||
var t = {};
|
var t = {};
|
||||||
if (typeof tx === 'string') {
|
if (typeof tx === 'string') {
|
||||||
|
|
||||||
|
console.log('[socket.js.22]',tx); //TODO
|
||||||
t = {
|
t = {
|
||||||
txid: tx
|
txid: tx
|
||||||
};
|
};
|
||||||
@ -31,6 +33,8 @@ module.exports.broadcastTx = function(tx) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
t.valueOut = parseInt(valueOut) / util.COIN;
|
t.valueOut = parseInt(valueOut) / util.COIN;
|
||||||
|
|
||||||
|
console.log('[socket.js.36]',t); //TODO
|
||||||
}
|
}
|
||||||
ios.sockets. in ('inv').emit('tx', t);
|
ios.sockets. in ('inv').emit('tx', t);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,9 @@ if (!config.disableP2pSync) {
|
|||||||
/**
|
/**
|
||||||
* historic_sync process
|
* historic_sync process
|
||||||
*/
|
*/
|
||||||
var historicSync = new HistoricSync({ shouldBroadcastSync: true });
|
var historicSync = new HistoricSync({
|
||||||
|
shouldBroadcastSync: true
|
||||||
|
});
|
||||||
peerSync.historicSync = historicSync;
|
peerSync.historicSync = historicSync;
|
||||||
|
|
||||||
if (!config.disableHistoricSync) {
|
if (!config.disableHistoricSync) {
|
||||||
|
|||||||
@ -264,7 +264,12 @@ function spec() {
|
|||||||
self.connectedCountDB > self.blockChainHeight * 0.9) return next();
|
self.connectedCountDB > self.blockChainHeight * 0.9) return next();
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
self.blockExtractor = new BlockExtractor(config.bitcoind.dataDir, config.network);
|
self.blockExtractor = new BlockExtractor(config.bitcoind.dataDir, config.network);
|
||||||
|
} catch (e) {
|
||||||
|
p(e.message + '. Disabling file sync.');
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
self.getFn = self.getBlockFromFile;
|
self.getFn = self.getBlockFromFile;
|
||||||
self.allowReorgs = true;
|
self.allowReorgs = true;
|
||||||
@ -407,6 +412,7 @@ function spec() {
|
|||||||
else {
|
else {
|
||||||
self.endTs = Date.now();
|
self.endTs = Date.now();
|
||||||
self.status = 'finished';
|
self.status = 'finished';
|
||||||
|
console.log('Done Syncing', self.info());
|
||||||
return w_cb(err);
|
return w_cb(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -265,6 +265,7 @@ function spec() {
|
|||||||
|
|
||||||
Sync.prototype.handleNewTx = function(data) {
|
Sync.prototype.handleNewTx = function(data) {
|
||||||
if (this.opts.shouldBroadcast) {
|
if (this.opts.shouldBroadcast) {
|
||||||
|
console.log('[Sync.js.268:shouldBroadcast:]', data.tx); //TODO
|
||||||
sockets.broadcastTx(data.tx);
|
sockets.broadcastTx(data.tx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -18,7 +18,9 @@ program
|
|||||||
.option('-v --verbose', 'Verbose 0/1', 0)
|
.option('-v --verbose', 'Verbose 0/1', 0)
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
var historicSync = new HistoricSync();
|
var historicSync = new HistoricSync({
|
||||||
|
shouldBroadcastSync: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user