updated docs for message commands
This commit is contained in:
parent
42985a7716
commit
f1aa4d3bc0
@ -28,7 +28,7 @@ function FilteraddMessage(options) {
|
||||
this.magicNumber = magicNumber;
|
||||
this.command = 'filteradd';
|
||||
this.data = options.data || BufferUtil.EMPTY_BUFFER;
|
||||
};
|
||||
}
|
||||
inherits(FilteraddMessage, Message);
|
||||
|
||||
FilteraddMessage.fromObject = function(options) {
|
||||
|
||||
@ -22,7 +22,7 @@ function FilterclearMessage(options) {
|
||||
Message.call(this, options);
|
||||
this.magicNumber = magicNumber;
|
||||
this.command = 'filterclear';
|
||||
};
|
||||
}
|
||||
inherits(FilterclearMessage, Message);
|
||||
|
||||
FilterclearMessage.fromObject = function(options) {
|
||||
|
||||
@ -7,6 +7,11 @@ var BufferUtil = bitcore.util.buffer;
|
||||
|
||||
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
|
||||
|
||||
/**
|
||||
* Request information about active peers
|
||||
* @extends Message
|
||||
* @constructor
|
||||
*/
|
||||
function GetaddrMessage(options) {
|
||||
if (!(this instanceof GetaddrMessage)) {
|
||||
return new GetaddrMessage(options);
|
||||
|
||||
@ -15,9 +15,9 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
|
||||
* 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
|
||||
* hashes.
|
||||
*
|
||||
* @param{Array} starts - array of buffers or strings with the starting block 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 GetblocksMessage(options) {
|
||||
if (!(this instanceof GetblocksMessage)) {
|
||||
@ -34,8 +34,7 @@ function GetblocksMessage(options) {
|
||||
options = utils.sanitizeStartStop(options);
|
||||
this.starts = options.starts;
|
||||
this.stop = options.stop;
|
||||
|
||||
};
|
||||
}
|
||||
inherits(GetblocksMessage, Message);
|
||||
|
||||
GetblocksMessage.fromObject = function(obj) {
|
||||
|
||||
@ -12,10 +12,12 @@ var protocolVersion = 70000;
|
||||
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
|
||||
|
||||
/**
|
||||
* Request block headers starting from a hash
|
||||
*
|
||||
* @param{Array} starts - array of buffers with the starting block hashes
|
||||
* @param{Buffer} [stop] - hash of the last block
|
||||
* 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
|
||||
* hashes.
|
||||
* @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) {
|
||||
if (!(this instanceof GetheadersMessage)) {
|
||||
@ -32,7 +34,6 @@ function GetheadersMessage(options) {
|
||||
options = utils.sanitizeStartStop(options);
|
||||
this.starts = options.starts;
|
||||
this.stop = options.stop;
|
||||
|
||||
}
|
||||
inherits(GetheadersMessage, Message);
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
|
||||
/**
|
||||
* Sent in response to a `getheaders` message. It contains information about
|
||||
* block headers.
|
||||
*
|
||||
* @param{Array} blockheaders - array of block headers
|
||||
* @param {Object} options
|
||||
* @param {Array} options.headers - array of block headers
|
||||
*/
|
||||
function HeadersMessage(options) {
|
||||
if (!(this instanceof HeadersMessage)) {
|
||||
@ -28,7 +28,7 @@ function HeadersMessage(options) {
|
||||
this.magicNumber = magicNumber;
|
||||
this.command = 'headers';
|
||||
this.headers = options.headers;
|
||||
};
|
||||
}
|
||||
inherits(HeadersMessage, Message);
|
||||
|
||||
HeadersMessage.fromObject = function(options) {
|
||||
|
||||
@ -7,6 +7,13 @@ var BufferUtil = bitcore.util.buffer;
|
||||
|
||||
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) {
|
||||
if (!(this instanceof MempoolMessage)) {
|
||||
return new MempoolMessage(options);
|
||||
|
||||
@ -12,9 +12,9 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
|
||||
|
||||
/**
|
||||
* Contains information about a MerkleBlock
|
||||
*
|
||||
* @name P2P.Message.MerkleBlock
|
||||
* @param {MerkleBlock} block
|
||||
* @see https://en.bitcoin.it/wiki/Protocol_documentation
|
||||
* @param {Object} options
|
||||
* @param {MerkleBlock} options.merkleBlock
|
||||
*/
|
||||
function MerkleblockMessage(options) {
|
||||
if (!(this instanceof MerkleblockMessage)) {
|
||||
|
||||
@ -8,6 +8,13 @@ var BufferReader = bitcore.encoding.BufferReader;
|
||||
|
||||
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) {
|
||||
if (!(this instanceof PingMessage)) {
|
||||
return new PingMessage(options);
|
||||
@ -19,7 +26,7 @@ function PingMessage(options) {
|
||||
this.command = 'ping';
|
||||
this.magicNumber = magicNumber;
|
||||
this.nonce = options.nonce || utils.getNonce();
|
||||
};
|
||||
}
|
||||
inherits(PingMessage, Message);
|
||||
|
||||
PingMessage.prototype.getPayload = function() {
|
||||
|
||||
@ -8,6 +8,13 @@ var BufferReader = bitcore.encoding.BufferReader;
|
||||
|
||||
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) {
|
||||
if (!(this instanceof PongMessage)) {
|
||||
return new PongMessage(options);
|
||||
|
||||
@ -18,7 +18,7 @@ function RejectMessage(options) {
|
||||
Message.call(this, options);
|
||||
this.magicNumber = magicNumber;
|
||||
this.command = 'reject';
|
||||
};
|
||||
}
|
||||
inherits(RejectMessage, Message);
|
||||
|
||||
RejectMessage.fromObject = function(options) {
|
||||
|
||||
@ -7,6 +7,11 @@ var BufferUtil = bitcore.util.buffer;
|
||||
|
||||
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
|
||||
|
||||
/**
|
||||
* A message in response to a version message.
|
||||
* @extends Message
|
||||
* @constructor
|
||||
*/
|
||||
function VerackMessage(options) {
|
||||
if (!(this instanceof VerackMessage)) {
|
||||
return new VerackMessage(options);
|
||||
@ -17,7 +22,7 @@ function VerackMessage(options) {
|
||||
Message.call(this, options);
|
||||
this.magicNumber = magicNumber;
|
||||
this.command = 'verack';
|
||||
};
|
||||
}
|
||||
inherits(VerackMessage, Message);
|
||||
|
||||
VerackMessage.fromObject = function(obj) {
|
||||
|
||||
@ -17,11 +17,16 @@ var packageInfo = require('../../../package.json');
|
||||
* The version message is used on connection creation to advertise
|
||||
* the type of node. The remote node will respond with its version, and no
|
||||
* 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
|
||||
* @param{String} obj.subversion - version of the client
|
||||
* @param{Buffer} obj.nonce - a random 8 byte buffer
|
||||
* @see https://en.bitcoin.it/wiki/Protocol_documentation#version
|
||||
* @param{Object} [obj] - properties for the version
|
||||
* @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) {
|
||||
if (!(this instanceof VersionMessage)) {
|
||||
@ -38,7 +43,7 @@ function VersionMessage(obj) {
|
||||
this.version = this.version || protocolVersion;
|
||||
this.subversion = this.subversion || '/bitcore:' + packageInfo.version + '/';
|
||||
this.startHeight = this.startHeight || 0;
|
||||
};
|
||||
}
|
||||
inherits(VersionMessage, Message);
|
||||
|
||||
VersionMessage.fromObject = function(obj) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user