Connection, const: add bits necessary for getheaders/headers
This commit is contained in:
parent
420773ac39
commit
5b69342356
@ -187,7 +187,7 @@ function spec(b) {
|
|||||||
this.sendMessage('version', put.buffer());
|
this.sendMessage('version', put.buffer());
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.sendGetBlocks = function (starts, stop) {
|
Connection.prototype.sendGetBlocks = function (starts, stop, wantHeaders) {
|
||||||
var put = new Put();
|
var put = new Put();
|
||||||
put.word32le(this.sendVer);
|
put.word32le(this.sendVer);
|
||||||
|
|
||||||
@ -207,7 +207,14 @@ function spec(b) {
|
|||||||
|
|
||||||
put.put(stopBuffer);
|
put.put(stopBuffer);
|
||||||
|
|
||||||
this.sendMessage('getblocks', put.buffer());
|
var command = 'getblocks';
|
||||||
|
if (wantHeaders)
|
||||||
|
command = 'getheaders';
|
||||||
|
this.sendMessage(command, put.buffer());
|
||||||
|
};
|
||||||
|
|
||||||
|
Connection.prototype.sendGetHeaders = function(starts, stop) {
|
||||||
|
this.sendGetBlocks(starts, stop, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection.prototype.sendGetData = function (invs) {
|
Connection.prototype.sendGetData = function (invs) {
|
||||||
@ -432,6 +439,17 @@ function spec(b) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'headers':
|
||||||
|
data.count = parser.varInt();
|
||||||
|
|
||||||
|
data.headers = [];
|
||||||
|
for (i = 0; i < data.count; i++) {
|
||||||
|
var header = new Block();
|
||||||
|
header.parse(parser);
|
||||||
|
data.headers.push(header);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'block':
|
case 'block':
|
||||||
var block = new Block();
|
var block = new Block();
|
||||||
block.parse(parser);
|
block.parse(parser);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user