diff --git a/lib/inventory.js b/lib/inventory.js index 42bb0fae..e0193eb5 100644 --- a/lib/inventory.js +++ b/lib/inventory.js @@ -84,6 +84,20 @@ Inventory.prototype.toBufferWriter = function(bw) { return bw; }; +/** + * @return {String} name of inventory type + */ +Inventory.prototype.typeName = function () { + return Inventory.TYPE_NAME[this.type]; +}; + +/** + * @return {String} name of inventory type : hash + */ +Inventory.prototype.toString = function () { + return this.typeName() + ':' + BufferUtil.reverse(this.hash).toString('hex'); +}; + /** * @param {Buffer} payload - Serialized buffer of the inventory */ diff --git a/lib/peer.js b/lib/peer.js index 25a4eaa9..7d450304 100644 --- a/lib/peer.js +++ b/lib/peer.js @@ -190,8 +190,8 @@ Peer.prototype.disconnect = function() { * Send a Message to the remote peer. * @param {Message} message - A message instance */ -Peer.prototype.sendMessage = function(message) { - this.socket.write(message.toBuffer()); +Peer.prototype.sendMessage = function(message, cb) { + this.socket.write(message.toBuffer(), cb); }; /** diff --git a/package.json b/package.json index 3c23831d..a28f796a 100644 --- a/package.json +++ b/package.json @@ -52,9 +52,9 @@ "url": "https://github.com/bitpay/bitcore-p2p.git" }, "dependencies": { - "bitcore": "^0.12.0", + "bitcore": "^0.13.0", "bloom-filter": "^0.2.0", - "buffers": "^0.1.1", + "buffers": "olalonde/node-buffers", "socks5-client": "^0.3.6" }, "devDependencies": {