Merge pull request #54 from braydonf/docs/fixes

update docs
This commit is contained in:
Eric Martindale 2015-03-26 14:08:20 -04:00
commit 4e605c18a0
23 changed files with 73 additions and 73 deletions

View File

@ -1,4 +1,5 @@
<img src="http://bitcore.io/css/images/bitcore-p2p.svg" alt="bitcore payment protocol" height="35" width="102"> <img src="http://bitcore.io/css/images/bitcore-p2p.svg" alt="bitcore payment protocol" height="35" width="102">
Bitcore P2P Bitcore P2P
======= =======

View File

@ -21,7 +21,7 @@ npm install bitcore-p2p --save
```javascript ```javascript
var Peer = require('bitcore-p2p').Peer; var Peer = require('bitcore-p2p').Peer;
var peer = new Peer('5.9.85.34'); var peer = new Peer({host: '5.9.85.34'});
// handle events // handle events
peer.on('inv', function(message) { peer.on('inv', function(message) {

View File

@ -10,9 +10,9 @@ var _ = bitcore.deps._;
/** /**
* A constructor for inventory related Bitcoin messages such as * A constructor for inventory related Bitcoin messages such as
* "getdata", "inv" and "notfound". * "getdata", "inv" and "notfound".
* @param {Object} - obj * @param {Object} obj
* @param {Number} - obj.type - Inventory.TYPE * @param {Number} obj.type - Inventory.TYPE
* @param {Buffer} - obj.hash - The hash for the inventory * @param {Buffer} obj.hash - The hash for the inventory
* @constructor * @constructor
*/ */
function Inventory(obj) { function Inventory(obj) {
@ -25,8 +25,8 @@ function Inventory(obj) {
/** /**
* A convenience constructor for Inventory. * A convenience constructor for Inventory.
* @param {Number} - type - Inventory.TYPE * @param {Number} type - Inventory.TYPE
* @param {Buffer|String} - hash - The hash for the inventory * @param {Buffer|String} hash - The hash for the inventory
* @returns {Inventory} - A new instance of Inventory * @returns {Inventory} - A new instance of Inventory
*/ */
Inventory.forItem = function(type, hash) { Inventory.forItem = function(type, hash) {
@ -40,7 +40,7 @@ Inventory.forItem = function(type, hash) {
/** /**
* A convenience constructor for Inventory for block inventory types. * A convenience constructor for Inventory for block inventory types.
* @param {Buffer|String} - hash - The hash for the block inventory * @param {Buffer|String} hash - The hash for the block inventory
* @returns {Inventory} - A new instance of Inventory * @returns {Inventory} - A new instance of Inventory
*/ */
Inventory.forBlock = function(hash) { Inventory.forBlock = function(hash) {
@ -49,7 +49,7 @@ Inventory.forBlock = function(hash) {
/** /**
* A convenience constructor for Inventory for filtered/merkle block inventory types. * A convenience constructor for Inventory for filtered/merkle block inventory types.
* @param {Buffer|String} - hash - The hash for the filtered block inventory * @param {Buffer|String} hash - The hash for the filtered block inventory
* @returns {Inventory} - A new instance of Inventory * @returns {Inventory} - A new instance of Inventory
*/ */
Inventory.forFilteredBlock = function(hash) { Inventory.forFilteredBlock = function(hash) {
@ -58,7 +58,7 @@ Inventory.forFilteredBlock = function(hash) {
/** /**
* A convenience constructor for Inventory for transaction inventory types. * A convenience constructor for Inventory for transaction inventory types.
* @param {Buffer|String} - hash - The hash for the transaction inventory * @param {Buffer|String} hash - The hash for the transaction inventory
* @returns {Inventory} - A new instance of Inventory * @returns {Inventory} - A new instance of Inventory
*/ */
Inventory.forTransaction = function(hash) { Inventory.forTransaction = function(hash) {
@ -76,7 +76,7 @@ Inventory.prototype.toBuffer = function() {
}; };
/** /**
* @param {BufferWriter} - An instance of BufferWriter * @param {BufferWriter} bw - An instance of BufferWriter
*/ */
Inventory.prototype.toBufferWriter = function(bw) { Inventory.prototype.toBufferWriter = function(bw) {
bw.writeUInt32LE(this.type); bw.writeUInt32LE(this.type);
@ -85,7 +85,7 @@ Inventory.prototype.toBufferWriter = function(bw) {
}; };
/** /**
* @param {Buffer} - Seralized buffer of the inventory * @param {Buffer} payload - Serialized buffer of the inventory
*/ */
Inventory.fromBuffer = function(payload) { Inventory.fromBuffer = function(payload) {
var parser = new BufferReader(payload); var parser = new BufferReader(payload);
@ -96,7 +96,7 @@ Inventory.fromBuffer = function(payload) {
}; };
/** /**
* @param {BufferWriter} - An instance of BufferWriter * @param {BufferWriter} br - An instance of BufferWriter
*/ */
Inventory.fromBufferReader = function(br) { Inventory.fromBufferReader = function(br) {
var obj = {}; var obj = {};

View File

@ -10,8 +10,8 @@ var BufferWriter = bitcore.encoding.BufferWriter;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* @param {Object} - options * @param {Object=} options
* @param {Array} - options.addresses - An array of addrs * @param {Array=} options.addresses - An array of addrs
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -10,9 +10,9 @@ var BufferWriter = bitcore.encoding.BufferWriter;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* @param {Object} - options * @param {Object=} options
* @param {Buffer} - options.payload * @param {Buffer=} options.payload
* @param {Buffer} - options.signature * @param {Buffer=} options.signature
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -8,8 +8,8 @@ var Block = bitcore.Block;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* @param {Object|Block} - options - If is an instance of Block will use as options.block * @param {Object|Block=} options - If is an instance of Block will use as options.block
* @param {Block} - options.block - An instance of a Block * @param {Block=} options.block - An instance of a Block
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -13,8 +13,8 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* Request peer to add data to a bloom filter already set by 'filterload' * Request peer to add data to a bloom filter already set by 'filterload'
* @param {Object} options * @param {Object=} options
* @param {Buffer} options.data - Array of bytes representing bloom filter data * @param {Buffer=} options.data - Array of bytes representing bloom filter data
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -12,7 +12,7 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* Request peer to send inv messages based on a bloom filter * Request peer to send inv messages based on a bloom filter
* @param {BloomFilter} options.filter - An instance of BloomFilter * @param {BloomFilter=} options.filter - An instance of BloomFilter
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

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 {Object=} options
* @param {Array} options.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} options.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)) {

View File

@ -6,14 +6,13 @@ var bitcore = require('bitcore');
var utils = require('../utils'); var utils = require('../utils');
var BufferReader = bitcore.encoding.BufferReader; var BufferReader = bitcore.encoding.BufferReader;
var BufferWriter = bitcore.encoding.BufferWriter; var BufferWriter = bitcore.encoding.BufferWriter;
var Inventory = require('../../inventory');
var _ = bitcore.deps._; var _ = bitcore.deps._;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* @param {Object|Array} - options - If options is an array will use as "inventory" * @param {Object|Array=} - options - If options is an array will use as "inventory"
* @param {Array} options.inventory - An array of inventory items * @param {Array=} options.inventory - An array of inventory items
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -15,9 +15,9 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
* Query another peer about block headers. It can query for multiple block hashes, * 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 * and the response will contain all the chains of blocks starting from those
* hashes. * hashes.
* @param {Object} options * @param {Object=} options
* @param {Array} options.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} options.stop - Hash of the last block * @param {Buffer=} options.stop - Hash of the last block
*/ */
function GetheadersMessage(options) { function GetheadersMessage(options) {
if (!(this instanceof GetheadersMessage)) { if (!(this instanceof GetheadersMessage)) {

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 {Object=} options
* @param {Array} options.headers - 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)) {

View File

@ -12,8 +12,8 @@ var _ = bitcore.deps._;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* @param {Object|Array} - options - If options is an array will use as "inventory" * @param {Object|Array=} - options - If options is an array will use as "inventory"
* @param {Array} options.inventory - An array of inventory items * @param {Array=} options.inventory - An array of inventory items
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -13,8 +13,8 @@ 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 * @see https://en.bitcoin.it/wiki/Protocol_documentation
* @param {Object} options * @param {Object=} options
* @param {MerkleBlock} options.merkleBlock * @param {MerkleBlock=} options.merkleBlock
*/ */
function MerkleblockMessage(options) { function MerkleblockMessage(options) {
if (!(this instanceof MerkleblockMessage)) { if (!(this instanceof MerkleblockMessage)) {

View File

@ -12,8 +12,8 @@ var _ = bitcore.deps._;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* @param {Object|Array} - options - If options is an array will use as "inventory" * @param {Object|Array=} options - If options is an array will use as "inventory"
* @param {Array} options.inventory - An array of inventory items * @param {Array=} options.inventory - An array of inventory items
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -10,8 +10,8 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* A message to confirm that a connection is still valid. * A message to confirm that a connection is still valid.
* @param {Object} options * @param {Object=} options
* @param {Buffer} options.nonce * @param {Buffer=} options.nonce
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -10,8 +10,8 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* A message in response to a ping message. * A message in response to a ping message.
* @param {Object} options * @param {Object=} options
* @param {Buffer} options.nonce * @param {Buffer=} options.nonce
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -8,8 +8,8 @@ var Transaction = bitcore.Transaction;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0); var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/** /**
* @param {Object|Transaction} - options - If is an instance of Transaction will use as options.transaction * @param {Object|Transaction=} options - If is an instance of Transaction will use as options.transaction
* @param {Transaction} - options.transaction - An instance of a Transaction * @param {Transaction=} options.transaction - An instance of a Transaction
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -19,12 +19,12 @@ var packageInfo = require('../../../package.json');
* communication is possible until both peers have exchanged their versions. * communication is possible until both peers have exchanged their versions.
* *
* @see https://en.bitcoin.it/wiki/Protocol_documentation#version * @see https://en.bitcoin.it/wiki/Protocol_documentation#version
* @param{Object} [obj] - properties for the version * @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 {String=} obj.subversion - version of the client
* @param{BN} [obj.services] * @param {BN=} obj.services
* @param{Date} [obj.timestamp] * @param {Date=} obj.timestamp
* @param{Number} [obj.startHeight] * @param {Number=} obj.startHeight
* @extends Message * @extends Message
* @constructor * @constructor
*/ */

View File

@ -6,12 +6,12 @@ var Hash = bitcore.crypto.Hash;
/** /**
* A factory to build Bitcoin protocol messages. * A factory to build Bitcoin protocol messages.
* @param {Object} - [options] * @param {Object=} options
* @param {Number} - [options.magicNumber] * @param {Number=} options.magicNumber
* @param {Function} - [options.Block] - A block constructor * @param {Function=} options.Block - A block constructor
* @param {Function} - [options.BlockHeader] - A block header constructor * @param {Function=} options.BlockHeader - A block header constructor
* @param {Function} - [options.MerkleBlock] - A merkle block constructor * @param {Function=} options.MerkleBlock - A merkle block constructor
* @param {Function} - [options.Transaction] - A transaction constructor * @param {Function=} options.Transaction - A transaction constructor
* @constructor * @constructor
*/ */
function Messages(options) { function Messages(options) {

View File

@ -7,9 +7,9 @@ var Hash = bitcore.crypto.Hash;
/** /**
* Base message that can be inherited to add an additional * Base message that can be inherited to add an additional
* `getPayload` method to modify the message payload. * `getPayload` method to modify the message payload.
* @param {Object} - options * @param {Object=} options
* @param {String} - options.command * @param {String=} options.command
* @param {Number} - options.magicNumber * @param {Number=} options.magicNumber
* @constructor * @constructor
*/ */
function Message(options) { function Message(options) {

View File

@ -27,12 +27,12 @@ var util = require('util');
* peer.connect(); * peer.connect();
* ``` * ```
* *
* @param {Object} [options] * @param {Object} options
* @param {String} [options.host] - IP address of the remote host * @param {String} options.host - IP address of the remote host
* @param {Number} [options.port] - Port number of the remote host * @param {Number} options.port - Port number of the remote host
* @param {Network} [options.network=Networks.defaultNetwork] - The network configuration * @param {Network} options.network - The network configuration
* @param {Boolean} [options.relay] - An option to disable automatic inventory relaying from the remote peer * @param {Boolean=} options.relay - An option to disable automatic inventory relaying from the remote peer
* @param {Socket} [options.socket] - An existing connected socket * @param {Socket=} options.socket - An existing connected socket
* @returns {Peer} A new instance of Peer. * @returns {Peer} A new instance of Peer.
* @constructor * @constructor
@ -222,7 +222,7 @@ Peer.prototype._readMessage = function() {
}; };
/** /**
* Internal function that creates a socket using a proxy if neccesary. * Internal function that creates a socket using a proxy if necessary.
* @returns {Socket} A Socket instance not yet connected. * @returns {Socket} A Socket instance not yet connected.
*/ */
Peer.prototype._getSocket = function() { Peer.prototype._getSocket = function() {

View File

@ -29,12 +29,12 @@ function now() {
* pool.connect(); * pool.connect();
* ``` * ```
* *
* @param {Object} [options] * @param {Object=} options
* @param {Network} [options.network=Networks.defaultNetwork] - The network configuration * @param {Network=} options.network - The network configuration
* @param {Boolean} [options.listenAddr=true] - Prevent new peers being added from addr messages * @param {Boolean=} options.listenAddr - Prevent new peers being added from addr messages
* @param {Boolean} [options.dnsSeed=true] - Prevent seeding with DNS discovered known peers * @param {Boolean=} options.dnsSeed - Prevent seeding with DNS discovered known peers
* @param {Boolean} [options.relay=true] - Prevent inventory announcements until a filter is loaded * @param {Boolean=} options.relay - Prevent inventory announcements until a filter is loaded
* @param {Number} [options.maxSize=Pool.MaxConnectedPeers] - The max number of peers * @param {Number=} options.maxSize - The max number of peers
* @returns {Pool} * @returns {Pool}
* @constructor * @constructor
*/ */