allow usage of the original non-spv pre BIP-37 satoshi protocol.

This commit is contained in:
Christopher Jeffrey 2014-05-23 10:06:29 -05:00
parent f4dbc0ee33
commit 7de6964628
2 changed files with 17 additions and 5 deletions

View File

@ -161,6 +161,7 @@ Peer.prototype.broadcast = function broadcast(items) {
}; };
Peer.prototype.updateWatch = function updateWatch() { Peer.prototype.updateWatch = function updateWatch() {
if (this.options.satoshi) return;
if (this.ack) if (this.ack)
this._write(this.framer.filterLoad(this.bloom, 'none')); this._write(this.framer.filterLoad(this.bloom, 'none'));
}; };
@ -417,6 +418,13 @@ Peer.prototype._handleInv = function handleInv(items) {
}); });
this.emit('blocks', blocks); this.emit('blocks', blocks);
if (this.options.satoshi) {
this.getData(items.filter(function(item) {
return item.type === 'block';
}));
return;
}
if (txs.length === 0) if (txs.length === 0)
return; return;

View File

@ -105,7 +105,8 @@ Pool.prototype._addLoader = function _addLoader() {
return; return;
var peer = new bcoin.peer(this, this.createConnection, { var peer = new bcoin.peer(this, this.createConnection, {
backoff: 750 * Math.random() backoff: 750 * Math.random(),
satoshi: this.options.satoshi
}); });
this.peers.load = peer; this.peers.load = peer;
@ -242,7 +243,8 @@ Pool.prototype._addPeer = function _addPeer(backoff) {
return; return;
var peer = new bcoin.peer(this, this.createConnection, { var peer = new bcoin.peer(this, this.createConnection, {
backoff: backoff backoff: backoff,
satoshi: this.options.satoshi
}); });
this.peers.pending.push(peer); this.peers.pending.push(peer);
@ -293,9 +295,11 @@ Pool.prototype._addPeer = function _addPeer(backoff) {
self.emit('block', block, peer); self.emit('block', block, peer);
}); });
peer.on('block', function(block) { if (this.options.satoshi) {
self.emit('block', block, peer); peer.on('block', function(block) {
}); self.emit('block', block, peer);
});
}
// Just FYI // Just FYI
peer.on('reject', function(payload) { peer.on('reject', function(payload) {