fix typos.

This commit is contained in:
Christopher Jeffrey 2016-05-22 22:12:03 -07:00
parent d85956b63f
commit 013b59a9cc
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
5 changed files with 37 additions and 11 deletions

View File

@ -38,6 +38,7 @@ node.open(function(err) {
if (node.network.type === 'regtest') {
node.miner.start();
node.startSync();
return;
}

View File

@ -95,7 +95,6 @@ function Peer(pool, options) {
this.hashContinue = null;
this.spvFilter = null;
this.relay = true;
this.localNonce = utils.nonce();
this.feeRate = -1;
this.addrFilter = new bcoin.bloom.rolling(5000, 0.001);
this.invFilter = new bcoin.bloom.rolling(50000, 0.000001);
@ -252,7 +251,7 @@ Peer.prototype._init = function init() {
this.write(this.framer.version({
height: this.chain.height,
relay: this.options.relay,
nonce: this.localNonce
nonce: this.pool.localNonce
}));
};
@ -975,10 +974,12 @@ Peer.prototype._handleVersion = function handleVersion(payload) {
var version = payload.version;
var services = payload.services;
if (payload.nonce.cmp(this.localNonce) === 0) {
this._error('We connected to ourself. Oops.');
this.setMisbehavior(100);
return;
if (this.network.type !== 'regtest') {
if (payload.nonce.cmp(this.pool.localNonce) === 0) {
this._error('We connected to ourself. Oops.');
this.setMisbehavior(100);
return;
}
}
if (version < constants.MIN_VERSION) {
@ -1128,6 +1129,11 @@ Peer.prototype._handleGetData = function handleGetData(items) {
return next();
}
if (tx.isCoinbase()) {
notfound.push({ type: constants.inv.TX, hash: hash });
return next();
}
data = witness
? self.framer.witnessTX(tx)
: self.framer.tx(tx);
@ -1345,9 +1351,12 @@ Peer.prototype._handleGetAddr = function handleGetAddr() {
break;
}
if (items.length === 0)
return;
bcoin.debug(
'Sending %d addrs to peer (%s)',
addrs.length,
items.length,
this.hostname);
return this.write(this.framer.addr(items));

View File

@ -138,6 +138,8 @@ function Pool(options) {
? bcoin.bloom.fromRate(10000, 0.01, constants.bloom.NONE)
: null;
this.localNonce = utils.nonce();
this.peers = {
// Peers that are loading blocks themselves
regular: [],
@ -2328,7 +2330,7 @@ BroadcastItem.prototype.finish = function finish(err) {
BroadcastItem.prototype.send = function send(peer, witness) {
var self = this;
var i, data;
var data;
if (!this.msg) {
this.ack(peer);
@ -2336,6 +2338,11 @@ BroadcastItem.prototype.send = function send(peer, witness) {
}
if (this.type === constants.inv.TX) {
if (this.msg.isCoinbase()) {
peer.write(peer.framer.notFound([this]));
return true;
}
data = witness
? peer.framer.witnessTX(this.msg)
: peer.framer.tx(this.msg);
@ -2345,7 +2352,7 @@ BroadcastItem.prototype.send = function send(peer, witness) {
: peer.framer.block(this.msg);
}
peer.write(value);
peer.write(data);
this.ack(peer);
@ -2359,6 +2366,7 @@ BroadcastItem.prototype.send = function send(peer, witness) {
BroadcastItem.prototype.ack = function ack(peer) {
var self = this;
var i;
setTimeout(function() {
self.emit('ack', peer);
@ -2395,7 +2403,7 @@ BroadcastItem.prototype.reject = function reject(peer) {
BroadcastItem.prototype.inspect = function inspect() {
return '<BroadcastItem:'
+ ' id=' + this.id
+ ' type=' + (this.type === constants.TX ? 'tx' : 'block')
+ ' type=' + (this.type === constants.inv.TX ? 'tx' : 'block')
+ ' hash=' + utils.revHex(this.hash)
+ '>';
};

View File

@ -2255,7 +2255,8 @@ Script.createCommitment = function createCommitment(hash) {
p.writeHash(hash);
return new Script([
opcodes.OP_RETURN,
p.render()
p.render(),
new Buffer('mined by bcoin', 'ascii')
]);
};

View File

@ -314,6 +314,10 @@ function Worker(pool, id) {
self.emit('error', err);
});
this.child.stdout.on('data', function(data) {
self.emit('data', data);
});
this.child.stderr.setEncoding('utf8');
this.child.stderr.on('data', function(data) {
bcoin.debug(data.trim());
@ -573,6 +577,9 @@ Master.prototype.debug = function debug() {
*/
Master.prototype.error = function error(err) {
if (!err)
return;
this.debug(err.message);
};