Skip to content

Commit 0de1c92

Browse files
tenthirtyonetenthirtyone
tenthirtyone
authored and
tenthirtyone
committed
bcoin config updated for log levels and network
1 parent b8e8926 commit 0de1c92

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/services/p2p/bcoin.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Bcoin.prototype.start = function() {
2020
self._bcoin.connect().then(function() {
2121
self.emitter.emit('connect');
2222
self._bcoin.startSync();
23+
self._bcoin.chain.on('block', function() {
24+
console.log('block');
25+
})
2326
});
2427
});
2528
};
@@ -35,8 +38,9 @@ Bcoin.prototype.stop = function() {
3538
Bcoin.prototype._getConfig = function(options) {
3639
var config = {
3740
checkpoints: true,
38-
network: options.network || 'main',
39-
listen: true
41+
network: options.bcoin_network || 'main',
42+
listen: true,
43+
logLevel: options.logLevel
4044
};
4145
if (options.prefix) {
4246
config.prefix = options.prefix;

lib/services/p2p/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ P2P.prototype._connect = function() {
176176
};
177177

178178
P2P.prototype._getBestHeight = function() {
179+
179180
if (this._peers === 0) {
180181
return 0;
181182
}
@@ -186,7 +187,7 @@ P2P.prototype._getBestHeight = function() {
186187
maxHeight = this._peers[i].bestHeight;
187188
this._peer = this._peers[i];
188189
}
189-
}
190+
}options.bcoin_network
190191
return maxHeight;
191192
};
192193

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

286287
};
287288

288-
289289
P2P.prototype._onPeerTx = function(peer, message) {
290290
var filteredMessage = this._applyMempoolFilter(message);
291291
if (filteredMessage) {
@@ -332,9 +332,16 @@ P2P.prototype._setResourceFilter = function(filter, resource) {
332332
};
333333

334334
P2P.prototype._startBcoin = function() {
335+
var logLevel;
336+
if (process.env.BITCORE_ENV === 'debug') {
337+
log.info('Debug mode detected, starting Bcoin logger');
338+
logLevel = 'info';
339+
}
340+
335341
this._bcoin = new Bcoin({
336342
network: this.node.network,
337-
prefix: this.node.datadir
343+
prefix: this.node.datadir,
344+
logLevel: logLevel,
338345
});
339346
this._bcoin.start();
340347
};

0 commit comments

Comments
 (0)