updated docs for message commands

This commit is contained in:
Braydon Fuller 2015-03-16 12:22:43 -04:00
parent 42985a7716
commit f1aa4d3bc0
13 changed files with 62 additions and 26 deletions

View File

@ -28,7 +28,7 @@ function FilteraddMessage(options) {
this.magicNumber = magicNumber; this.magicNumber = magicNumber;
this.command = 'filteradd'; this.command = 'filteradd';
this.data = options.data || BufferUtil.EMPTY_BUFFER; this.data = options.data || BufferUtil.EMPTY_BUFFER;
}; }
inherits(FilteraddMessage, Message); inherits(FilteraddMessage, Message);
FilteraddMessage.fromObject = function(options) { FilteraddMessage.fromObject = function(options) {

View File

@ -22,7 +22,7 @@ function FilterclearMessage(options) {
Message.call(this, options); Message.call(this, options);
this.magicNumber = magicNumber; this.magicNumber = magicNumber;
this.command = 'filterclear'; this.command = 'filterclear';
}; }
inherits(FilterclearMessage, Message); inherits(FilterclearMessage, Message);
FilterclearMessage.fromObject = function(options) { FilterclearMessage.fromObject = function(options) {

View File

@ -7,6 +7,11 @@ var BufferUtil = bitcore.util.buffer;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/**
* Request information about active peers
* @extends Message
* @constructor
*/
function GetaddrMessage(options) { function GetaddrMessage(options) {
if (!(this instanceof GetaddrMessage)) { if (!(this instanceof GetaddrMessage)) {
return new GetaddrMessage(options); return new GetaddrMessage(options);

View File

@ -15,9 +15,9 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
* Query another peer about blocks. It can query for multiple block hashes, * Query another peer about blocks. It can query for multiple block hashes,
* and the response will contain all the chains of blocks starting from those * and the response will contain all the chains of blocks starting from those
* hashes. * hashes.
* * @param {Object} options
* @param{Array} starts - array of buffers or strings with the starting block hashes * @param {Array} options.starts - Array of buffers or strings with the starting block hashes
* @param{Buffer} [stop] - hash of the last block * @param {Buffer} options.stop - Hash of the last block
*/ */
function GetblocksMessage(options) { function GetblocksMessage(options) {
if (!(this instanceof GetblocksMessage)) { if (!(this instanceof GetblocksMessage)) {
@ -34,8 +34,7 @@ function GetblocksMessage(options) {
options = utils.sanitizeStartStop(options); options = utils.sanitizeStartStop(options);
this.starts = options.starts; this.starts = options.starts;
this.stop = options.stop; this.stop = options.stop;
}
};
inherits(GetblocksMessage, Message); inherits(GetblocksMessage, Message);
GetblocksMessage.fromObject = function(obj) { GetblocksMessage.fromObject = function(obj) {

View File

@ -12,10 +12,12 @@ var protocolVersion = 70000;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* Request block headers starting from a hash * Query another peer about block headers. It can query for multiple block hashes,
* * and the response will contain all the chains of blocks starting from those
* @param{Array} starts - array of buffers with the starting block hashes * hashes.
* @param{Buffer} [stop] - hash of the last block * @param {Object} options
* @param {Array} options.starts - Array of buffers or strings with the starting block hashes
* @param {Buffer} options.stop - Hash of the last block
*/ */
function GetheadersMessage(options) { function GetheadersMessage(options) {
if (!(this instanceof GetheadersMessage)) { if (!(this instanceof GetheadersMessage)) {
@ -32,7 +34,6 @@ function GetheadersMessage(options) {
options = utils.sanitizeStartStop(options); options = utils.sanitizeStartStop(options);
this.starts = options.starts; this.starts = options.starts;
this.stop = options.stop; this.stop = options.stop;
} }
inherits(GetheadersMessage, Message); inherits(GetheadersMessage, Message);

View File

@ -14,8 +14,8 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* Sent in response to a `getheaders` message. It contains information about * Sent in response to a `getheaders` message. It contains information about
* block headers. * block headers.
* * @param {Object} options
* @param{Array} blockheaders - array of block headers * @param {Array} options.headers - array of block headers
*/ */
function HeadersMessage(options) { function HeadersMessage(options) {
if (!(this instanceof HeadersMessage)) { if (!(this instanceof HeadersMessage)) {
@ -28,7 +28,7 @@ function HeadersMessage(options) {
this.magicNumber = magicNumber; this.magicNumber = magicNumber;
this.command = 'headers'; this.command = 'headers';
this.headers = options.headers; this.headers = options.headers;
}; }
inherits(HeadersMessage, Message); inherits(HeadersMessage, Message);
HeadersMessage.fromObject = function(options) { HeadersMessage.fromObject = function(options) {

View File

@ -7,6 +7,13 @@ var BufferUtil = bitcore.util.buffer;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/**
* The mempool message sends a request to a node asking for information about
* transactions it has verified but which have not yet confirmed.
* @see https://en.bitcoin.it/wiki/Protocol_documentation#mempool
* @extends Message
* @constructor
*/
function MempoolMessage(options) { function MempoolMessage(options) {
if (!(this instanceof MempoolMessage)) { if (!(this instanceof MempoolMessage)) {
return new MempoolMessage(options); return new MempoolMessage(options);

View File

@ -12,9 +12,9 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* Contains information about a MerkleBlock * Contains information about a MerkleBlock
* * @see https://en.bitcoin.it/wiki/Protocol_documentation
* @name P2P.Message.MerkleBlock * @param {Object} options
* @param {MerkleBlock} block * @param {MerkleBlock} options.merkleBlock
*/ */
function MerkleblockMessage(options) { function MerkleblockMessage(options) {
if (!(this instanceof MerkleblockMessage)) { if (!(this instanceof MerkleblockMessage)) {

View File

@ -8,6 +8,13 @@ var BufferReader = bitcore.encoding.BufferReader;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/**
* A message to confirm that a connection is still valid.
* @param {Object} options
* @param {Buffer} options.nonce
* @extends Message
* @constructor
*/
function PingMessage(options) { function PingMessage(options) {
if (!(this instanceof PingMessage)) { if (!(this instanceof PingMessage)) {
return new PingMessage(options); return new PingMessage(options);
@ -19,7 +26,7 @@ function PingMessage(options) {
this.command = 'ping'; this.command = 'ping';
this.magicNumber = magicNumber; this.magicNumber = magicNumber;
this.nonce = options.nonce || utils.getNonce(); this.nonce = options.nonce || utils.getNonce();
}; }
inherits(PingMessage, Message); inherits(PingMessage, Message);
PingMessage.prototype.getPayload = function() { PingMessage.prototype.getPayload = function() {

View File

@ -8,6 +8,13 @@ var BufferReader = bitcore.encoding.BufferReader;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/**
* A message in response to a ping message.
* @param {Object} options
* @param {Buffer} options.nonce
* @extends Message
* @constructor
*/
function PongMessage(options) { function PongMessage(options) {
if (!(this instanceof PongMessage)) { if (!(this instanceof PongMessage)) {
return new PongMessage(options); return new PongMessage(options);

View File

@ -18,7 +18,7 @@ function RejectMessage(options) {
Message.call(this, options); Message.call(this, options);
this.magicNumber = magicNumber; this.magicNumber = magicNumber;
this.command = 'reject'; this.command = 'reject';
}; }
inherits(RejectMessage, Message); inherits(RejectMessage, Message);
RejectMessage.fromObject = function(options) { RejectMessage.fromObject = function(options) {

View File

@ -7,6 +7,11 @@ var BufferUtil = bitcore.util.buffer;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/**
* A message in response to a version message.
* @extends Message
* @constructor
*/
function VerackMessage(options) { function VerackMessage(options) {
if (!(this instanceof VerackMessage)) { if (!(this instanceof VerackMessage)) {
return new VerackMessage(options); return new VerackMessage(options);
@ -17,7 +22,7 @@ function VerackMessage(options) {
Message.call(this, options); Message.call(this, options);
this.magicNumber = magicNumber; this.magicNumber = magicNumber;
this.command = 'verack'; this.command = 'verack';
}; }
inherits(VerackMessage, Message); inherits(VerackMessage, Message);
VerackMessage.fromObject = function(obj) { VerackMessage.fromObject = function(obj) {

View File

@ -17,11 +17,16 @@ var packageInfo = require('../../../package.json');
* The version message is used on connection creation to advertise * The version message is used on connection creation to advertise
* the type of node. The remote node will respond with its version, and no * the type of node. The remote node will respond with its version, and no
* communication is possible until both peers have exchanged their versions. * communication is possible until both peers have exchanged their versions.
* By default, bitcore advertises itself as named `bitcore:0.8`.
* *
* @param{Object} obj - properties for the version * @see https://en.bitcoin.it/wiki/Protocol_documentation#version
* @param{String} obj.subversion - version of the client * @param{Object} [obj] - properties for the version
* @param{Buffer} obj.nonce - a random 8 byte buffer * @param{Buffer} [obj.nonce] - a random 8 byte buffer
* @param{String} [obj.subversion] - version of the client
* @param{BN} [obj.services]
* @param{Date} [obj.timestamp]
* @param{Number} [obj.startHeight]
* @extends Message
* @constructor
*/ */
function VersionMessage(obj) { function VersionMessage(obj) {
if (!(this instanceof VersionMessage)) { if (!(this instanceof VersionMessage)) {
@ -38,7 +43,7 @@ function VersionMessage(obj) {
this.version = this.version || protocolVersion; this.version = this.version || protocolVersion;
this.subversion = this.subversion || '/bitcore:' + packageInfo.version + '/'; this.subversion = this.subversion || '/bitcore:' + packageInfo.version + '/';
this.startHeight = this.startHeight || 0; this.startHeight = this.startHeight || 0;
}; }
inherits(VersionMessage, Message); inherits(VersionMessage, Message);
VersionMessage.fromObject = function(obj) { VersionMessage.fromObject = function(obj) {