Connection: default value for sendGetBlocks

This commit is contained in:
olalonde 2014-04-08 14:38:00 +08:00
parent e130a3fe4b
commit 9d53ef5106

View File

@ -186,10 +186,15 @@ Connection.prototype.sendVersion = function () {
}; };
Connection.prototype.sendGetBlocks = function (starts, stop, wantHeaders) { Connection.prototype.sendGetBlocks = function (starts, stop, wantHeaders) {
var put = new Put(); // Default value for stop is 0 to get as many blocks as possible (500)
put.word32le(this.sendVer); stop = stop || '00000000000000000000000000000000';
var put = new Put();
// https://en.bitcoin.it/wiki/Protocol_specification#getblocks
put.word32le(this.sendVer);
put.varint(starts.length); put.varint(starts.length);
for (var i = 0; i < starts.length; i++) { for (var i = 0; i < starts.length; i++) {
if (starts[i].length != 32) { if (starts[i].length != 32) {
throw new Error('Invalid hash length'); throw new Error('Invalid hash length');