more debugging.
This commit is contained in:
parent
271ca1aa52
commit
ef44bf44f0
@ -10,7 +10,11 @@ var bn = require('bn.js');
|
||||
var hash = require('hash.js');
|
||||
var async = require('async');
|
||||
|
||||
bcoin.debug = +process.env.BCOIN_DEBUG === 1;
|
||||
if (process.env.BCOIN_DEBUG) {
|
||||
bcoin.debug = process.env.BCOIN_DEBUG;
|
||||
if (bcoin.debug === '0' || bcoin.debug === '1')
|
||||
bcoin.debug = +bcoin.debug === 1;
|
||||
}
|
||||
|
||||
bcoin.ecdsa = elliptic.ec('secp256k1');
|
||||
bcoin.utils = require('./bcoin/utils');
|
||||
|
||||
@ -30,7 +30,7 @@ function Chain(options) {
|
||||
this.strict = this.options.strict || false;
|
||||
|
||||
if (this.options.debug)
|
||||
bcoin.debug = true;
|
||||
bcoin.debug = this.options.debug;
|
||||
|
||||
this.tip = null;
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ function Pool(options) {
|
||||
this.options = options || {};
|
||||
|
||||
if (this.options.debug)
|
||||
bcoin.debug = true;
|
||||
bcoin.debug = this.options.debug;
|
||||
|
||||
if (this.options.network)
|
||||
network.set(this.options.network);
|
||||
@ -70,6 +70,7 @@ function Pool(options) {
|
||||
this.options.multiplePeers = false;
|
||||
|
||||
this.syncing = false;
|
||||
this.synced = false;
|
||||
|
||||
this.backoff = {
|
||||
delta: options.backoffDelta || 500,
|
||||
@ -174,10 +175,12 @@ Pool.prototype._init = function _init() {
|
||||
var self = this;
|
||||
var i;
|
||||
|
||||
this._addLoader();
|
||||
if (this.originalSeeds.length > 0) {
|
||||
this._addLoader();
|
||||
|
||||
for (i = 0; i < this.size; i++)
|
||||
this._addPeer(0);
|
||||
for (i = 0; i < this.size; i++)
|
||||
this._addPeer(0);
|
||||
}
|
||||
|
||||
this.chain.on('block', function(block, peer) {
|
||||
self.emit('block', block, peer);
|
||||
@ -216,7 +219,7 @@ Pool.prototype._init = function _init() {
|
||||
|
||||
this.chain.on('invalid', function(data, peer) {
|
||||
utils.debug(
|
||||
'Invalid block at height: %d: hash=%s peer=%s',
|
||||
'Invalid block at height %d: hash=%s peer=%s',
|
||||
data.height,
|
||||
utils.revHex(data.hash),
|
||||
peer ? peer.host : ''
|
||||
@ -233,6 +236,13 @@ Pool.prototype._init = function _init() {
|
||||
this.options.wallets.forEach(function(w) {
|
||||
self.addWallet(w);
|
||||
});
|
||||
|
||||
// Chain is full and up-to-date
|
||||
if (this.chain.isFull()) {
|
||||
this.synced = true;
|
||||
this.emit('full');
|
||||
utils.debug('Chain is fully synced (height=%d).', this.chain.height());
|
||||
}
|
||||
};
|
||||
|
||||
Pool.prototype._startTimer = function _startTimer() {
|
||||
@ -247,12 +257,16 @@ Pool.prototype._startTimer = function _startTimer() {
|
||||
// Chain is full and up-to-date
|
||||
if (self.chain.isFull()) {
|
||||
self._stopTimer();
|
||||
self.synced = true;
|
||||
self.emit('full');
|
||||
utils.debug('Chain is fully synced (height=%d).', self.chain.height());
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.peers.load)
|
||||
if (self.peers.load) {
|
||||
self.peers.load.destroy();
|
||||
utils.debug('Timer ran out. Finding new loader peer.');
|
||||
}
|
||||
}
|
||||
|
||||
this._timer = setTimeout(destroy, this.load.timeout);
|
||||
@ -274,6 +288,7 @@ Pool.prototype._startInterval = function _startInterval() {
|
||||
function load() {
|
||||
if (!self.syncing)
|
||||
return;
|
||||
utils.debug('Stall recovery: loading again.');
|
||||
// self._load();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user