Skip to content

Commit

Permalink
Merge pull request #54 from braydonf/docs/fixes
Browse files Browse the repository at this point in the history
update docs
  • Loading branch information
martindale committed Mar 26, 2015
2 parents fa06ce0 + 573354a commit 4e605c1
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 73 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<img src="http://bitcore.io/css/images/bitcore-p2p.svg" alt="bitcore payment protocol" height="35" width="102">

Bitcore P2P
=======

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm install bitcore-p2p --save

```javascript
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
peer.on('inv', function(message) {
Expand Down
22 changes: 11 additions & 11 deletions lib/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var _ = bitcore.deps._;
/**
* A constructor for inventory related Bitcoin messages such as
* "getdata", "inv" and "notfound".
* @param {Object} - obj
* @param {Number} - obj.type - Inventory.TYPE
* @param {Buffer} - obj.hash - The hash for the inventory
* @param {Object} obj
* @param {Number} obj.type - Inventory.TYPE
* @param {Buffer} obj.hash - The hash for the inventory
* @constructor
*/
function Inventory(obj) {
Expand All @@ -25,8 +25,8 @@ function Inventory(obj) {

/**
* A convenience constructor for Inventory.
* @param {Number} - type - Inventory.TYPE
* @param {Buffer|String} - hash - The hash for the inventory
* @param {Number} type - Inventory.TYPE
* @param {Buffer|String} hash - The hash for the inventory
* @returns {Inventory} - A new instance of Inventory
*/
Inventory.forItem = function(type, hash) {
Expand All @@ -40,7 +40,7 @@ Inventory.forItem = function(type, hash) {

/**
* 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
*/
Inventory.forBlock = function(hash) {
Expand All @@ -49,7 +49,7 @@ Inventory.forBlock = function(hash) {

/**
* 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
*/
Inventory.forFilteredBlock = function(hash) {
Expand All @@ -58,7 +58,7 @@ Inventory.forFilteredBlock = function(hash) {

/**
* 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
*/
Inventory.forTransaction = function(hash) {
Expand All @@ -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) {
bw.writeUInt32LE(this.type);
Expand All @@ -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) {
var parser = new BufferReader(payload);
Expand All @@ -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) {
var obj = {};
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/addr.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var BufferWriter = bitcore.encoding.BufferWriter;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* @param {Object} - options
* @param {Array} - options.addresses - An array of addrs
* @param {Object=} options
* @param {Array=} options.addresses - An array of addrs
* @extends Message
* @constructor
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/messages/commands/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var BufferWriter = bitcore.encoding.BufferWriter;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* @param {Object} - options
* @param {Buffer} - options.payload
* @param {Buffer} - options.signature
* @param {Object=} options
* @param {Buffer=} options.payload
* @param {Buffer=} options.signature
* @extends Message
* @constructor
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ var Block = bitcore.Block;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* @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 {Object|Block=} options - If is an instance of Block will use as options.block
* @param {Block=} options.block - An instance of a Block
* @extends Message
* @constructor
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/filteradd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
* @param {Object} options
* @param {Buffer} options.data - Array of bytes representing bloom filter data
* @param {Object=} options
* @param {Buffer=} options.data - Array of bytes representing bloom filter data
* @extends Message
* @constructor
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/messages/commands/filterload.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* 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
* @constructor
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/messages/commands/getblocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {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
* @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)) {
Expand Down
5 changes: 2 additions & 3 deletions lib/messages/commands/getdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ var bitcore = require('bitcore');
var utils = require('../utils');
var BufferReader = bitcore.encoding.BufferReader;
var BufferWriter = bitcore.encoding.BufferWriter;
var Inventory = require('../../inventory');
var _ = bitcore.deps._;

var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* @param {Object|Array} - options - If options is an array will use as "inventory"
* @param {Array} options.inventory - An array of inventory items
* @param {Object|Array=} - options - If options is an array will use as "inventory"
* @param {Array=} options.inventory - An array of inventory items
* @extends Message
* @constructor
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/messages/commands/getheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
* 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
* @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)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {Object} options
* @param {Array} options.headers - array of block headers
* @param {Object=} options
* @param {Array=} options.headers - array of block headers
*/
function HeadersMessage(options) {
if (!(this instanceof HeadersMessage)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/inv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ var _ = bitcore.deps._;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* @param {Object|Array} - options - If options is an array will use as "inventory"
* @param {Array} options.inventory - An array of inventory items
* @param {Object|Array=} - options - If options is an array will use as "inventory"
* @param {Array=} options.inventory - An array of inventory items
* @extends Message
* @constructor
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/merkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);
/**
* Contains information about a MerkleBlock
* @see https://en.bitcoin.it/wiki/Protocol_documentation
* @param {Object} options
* @param {MerkleBlock} options.merkleBlock
* @param {Object=} options
* @param {MerkleBlock=} options.merkleBlock
*/
function MerkleblockMessage(options) {
if (!(this instanceof MerkleblockMessage)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/notfound.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ var _ = bitcore.deps._;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* @param {Object|Array} - options - If options is an array will use as "inventory"
* @param {Array} options.inventory - An array of inventory items
* @param {Object|Array=} options - If options is an array will use as "inventory"
* @param {Array=} options.inventory - An array of inventory items
* @extends Message
* @constructor
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/ping.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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
* @param {Object=} options
* @param {Buffer=} options.nonce
* @extends Message
* @constructor
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/pong.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* A message in response to a ping message.
* @param {Object} options
* @param {Buffer} options.nonce
* @param {Object=} options
* @param {Buffer=} options.nonce
* @extends Message
* @constructor
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/messages/commands/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ var Transaction = bitcore.Transaction;
var magicNumber = bitcore.Networks.defaultNetwork.networkMagic.readUInt32LE(0);

/**
* @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 {Object|Transaction=} options - If is an instance of Transaction will use as options.transaction
* @param {Transaction=} options.transaction - An instance of a Transaction
* @extends Message
* @constructor
*/
Expand Down
12 changes: 6 additions & 6 deletions lib/messages/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ var packageInfo = require('../../../package.json');
* communication is possible until both peers have exchanged their versions.
*
* @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]
* @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
*/
Expand Down
12 changes: 6 additions & 6 deletions lib/messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ var Hash = bitcore.crypto.Hash;

/**
* A factory to build Bitcoin protocol messages.
* @param {Object} - [options]
* @param {Number} - [options.magicNumber]
* @param {Function} - [options.Block] - A block constructor
* @param {Function} - [options.BlockHeader] - A block header constructor
* @param {Function} - [options.MerkleBlock] - A merkle block constructor
* @param {Function} - [options.Transaction] - A transaction constructor
* @param {Object=} options
* @param {Number=} options.magicNumber
* @param {Function=} options.Block - A block constructor
* @param {Function=} options.BlockHeader - A block header constructor
* @param {Function=} options.MerkleBlock - A merkle block constructor
* @param {Function=} options.Transaction - A transaction constructor
* @constructor
*/
function Messages(options) {
Expand Down
6 changes: 3 additions & 3 deletions lib/messages/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var Hash = bitcore.crypto.Hash;
/**
* Base message that can be inherited to add an additional
* `getPayload` method to modify the message payload.
* @param {Object} - options
* @param {String} - options.command
* @param {Number} - options.magicNumber
* @param {Object=} options
* @param {String=} options.command
* @param {Number=} options.magicNumber
* @constructor
*/
function Message(options) {
Expand Down
14 changes: 7 additions & 7 deletions lib/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ var util = require('util');
* peer.connect();
* ```
*
* @param {Object} [options]
* @param {String} [options.host] - IP address of the remote host
* @param {Number} [options.port] - Port number of the remote host
* @param {Network} [options.network=Networks.defaultNetwork] - The network configuration
* @param {Boolean} [options.relay] - An option to disable automatic inventory relaying from the remote peer
* @param {Socket} [options.socket] - An existing connected socket
* @param {Object} options
* @param {String} options.host - IP address of the remote host
* @param {Number} options.port - Port number of the remote host
* @param {Network} options.network - The network configuration
* @param {Boolean=} options.relay - An option to disable automatic inventory relaying from the remote peer
* @param {Socket=} options.socket - An existing connected socket
* @returns {Peer} A new instance of Peer.
* @constructor
Expand Down Expand Up @@ -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.
*/
Peer.prototype._getSocket = function() {
Expand Down
12 changes: 6 additions & 6 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ function now() {
* pool.connect();
* ```
*
* @param {Object} [options]
* @param {Network} [options.network=Networks.defaultNetwork] - The network configuration
* @param {Boolean} [options.listenAddr=true] - Prevent new peers being added from addr messages
* @param {Boolean} [options.dnsSeed=true] - Prevent seeding with DNS discovered known peers
* @param {Boolean} [options.relay=true] - Prevent inventory announcements until a filter is loaded
* @param {Number} [options.maxSize=Pool.MaxConnectedPeers] - The max number of peers
* @param {Object=} options
* @param {Network=} options.network - The network configuration
* @param {Boolean=} options.listenAddr - Prevent new peers being added from addr messages
* @param {Boolean=} options.dnsSeed - Prevent seeding with DNS discovered known peers
* @param {Boolean=} options.relay - Prevent inventory announcements until a filter is loaded
* @param {Number=} options.maxSize - The max number of peers
* @returns {Pool}
* @constructor
*/
Expand Down

0 comments on commit 4e605c1

Please sign in to comment.