Skip to content

Commit

Permalink
bcoin config updated for log levels and network
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthirtyone authored and tenthirtyone committed Jul 31, 2017
1 parent b8e8926 commit 0de1c92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/services/p2p/bcoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Bcoin.prototype.start = function() {
self._bcoin.connect().then(function() {
self.emitter.emit('connect');
self._bcoin.startSync();
self._bcoin.chain.on('block', function() {
console.log('block');
})
});
});
};
Expand All @@ -35,8 +38,9 @@ Bcoin.prototype.stop = function() {
Bcoin.prototype._getConfig = function(options) {
var config = {
checkpoints: true,
network: options.network || 'main',
listen: true
network: options.bcoin_network || 'main',
listen: true,
logLevel: options.logLevel
};
if (options.prefix) {
config.prefix = options.prefix;
Expand Down
13 changes: 10 additions & 3 deletions lib/services/p2p/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ P2P.prototype._connect = function() {
};

P2P.prototype._getBestHeight = function() {

if (this._peers === 0) {
return 0;
}
Expand All @@ -186,7 +187,7 @@ P2P.prototype._getBestHeight = function() {
maxHeight = this._peers[i].bestHeight;
this._peer = this._peers[i];
}
}
}options.bcoin_network
return maxHeight;
};

Expand Down Expand Up @@ -285,7 +286,6 @@ P2P.prototype._onPeerReady = function(peer, addr) {

};


P2P.prototype._onPeerTx = function(peer, message) {
var filteredMessage = this._applyMempoolFilter(message);
if (filteredMessage) {
Expand Down Expand Up @@ -332,9 +332,16 @@ P2P.prototype._setResourceFilter = function(filter, resource) {
};

P2P.prototype._startBcoin = function() {
var logLevel;
if (process.env.BITCORE_ENV === 'debug') {
log.info('Debug mode detected, starting Bcoin logger');
logLevel = 'info';
}

this._bcoin = new Bcoin({
network: this.node.network,
prefix: this.node.datadir
prefix: this.node.datadir,
logLevel: logLevel,
});
this._bcoin.start();
};
Expand Down

0 comments on commit 0de1c92

Please sign in to comment.