Closed maraoz closed 9 years ago
I think it's more simple to use an object argument since there are multiple params 'starts' and 'stop', rather than having multiple types that are handled in different ways.
var message = messages.GetBlocks({starts: starts});
Though since stop may often be omitted, optionally using an array may make sense. I think it would be better to handle this earlier in lib/messages/commands/getblocks.js
:
function GetblocksMessage(arg, options) {
Message.call(this, options);
this.command = 'getblocks';
this.version = options.protocolVersion;
this.magicNumber = options.magicNumber;
if (Array.isArray(arg)) {
arg = {
starts: arg
}
} else if (!arg) {
arg = {};
}
arg = utils.sanitizeStartStop(arg);
this.starts = arg.starts;
this.stop = arg.stop;
}
And we'll need to update the JSDocs for arg
to indicate that an object or array can be used, and if it's an array it will be considered "starts".
This allows a user of GetBlocks to do: