framer: version packet options, relay and height.

This commit is contained in:
Christopher Jeffrey 2014-05-20 04:06:19 -05:00
parent bbe1b71a14
commit a5f20114e8
3 changed files with 15 additions and 4 deletions

View File

@ -97,7 +97,14 @@ Peer.prototype._init = function init() {
}, this._ping.interval);
// Send hello
this._write(this.framer.version());
this._write(this.framer.version({
height: this.options.startHeight != null
? this.options.startHeight
: 0,
//: this.pool.chain.index.heights[this.pool.chain.index.heights.length-1],
relay: this.options.relay
}));
this._req('verack', function(err, payload) {
if (err)
return self._error(err);

View File

@ -105,7 +105,9 @@ Pool.prototype._addLoader = function _addLoader() {
return;
var peer = new bcoin.peer(this, this.createConnection, {
backoff: 750 * Math.random()
backoff: 750 * Math.random(),
startHeight: this.options.startHeight,
relay: this.options.relay
});
this.peers.load = peer;
@ -242,7 +244,9 @@ Pool.prototype._addPeer = function _addPeer(backoff) {
return;
var peer = new bcoin.peer(this, this.createConnection, {
backoff: backoff
backoff: backoff,
startHeight: this.options.startHeight,
relay: this.options.relay
});
this.peers.pending.push(peer);

View File

@ -97,7 +97,7 @@ Framer.prototype.version = function version(packet) {
}
// Start height
off += writeU32(p, packet.height, off);
off += writeU32(p, packet.height || 0, off);
// Relay
p[off++] = packet.relay ? 1 : 0;