Comparing version 4.0.2 to 4.1.0
var krpc = require('./') | ||
var rpc = krpc() | ||
var target = new Buffer('aaaabbbbccccddddeeeeffffaaaabbbbccccdddd', 'hex') | ||
var target = Buffer.from('aaaabbbbccccddddeeeeffffaaaabbbbccccdddd', 'hex') | ||
@@ -6,0 +6,0 @@ rpc.on('query', function (query, peer) { |
10
index.js
@@ -7,2 +7,3 @@ var socket = require('k-rpc-socket') | ||
var util = require('util') | ||
var Buffer = require('safe-buffer').Buffer | ||
@@ -104,4 +105,5 @@ var K = 20 | ||
RPC.prototype.bind = function (port, cb) { | ||
this.socket.bind(port, cb) | ||
// bind([port], [address], [callback]) | ||
RPC.prototype.bind = function () { | ||
this.socket.bind.apply(this.socket, arguments) | ||
} | ||
@@ -297,3 +299,3 @@ | ||
function encodeNodes (nodes) { | ||
var buf = new Buffer(nodes.length * 26) | ||
var buf = Buffer.allocUnsafe(nodes.length * 26) | ||
var ptr = 0 | ||
@@ -350,5 +352,5 @@ | ||
function toBuffer (str) { | ||
if (typeof str === 'string') return new Buffer(str, 'hex') | ||
if (typeof str === 'string') return Buffer.from(str, 'hex') | ||
if (Buffer.isBuffer(str)) return str | ||
throw new Error('Pass a buffer or a string') | ||
} |
{ | ||
"name": "k-rpc", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "Low-level implementation of the k-rpc protocol used the BitTorrent DHT.", | ||
@@ -9,3 +9,4 @@ "main": "index.js", | ||
"k-bucket": "^3.0.1", | ||
"k-rpc-socket": "^1.5.0" | ||
"k-rpc-socket": "^1.7.0", | ||
"safe-buffer": "^5.1.1" | ||
}, | ||
@@ -12,0 +13,0 @@ "devDependencies": { |
@@ -62,3 +62,3 @@ # k-rpc | ||
#### `rpc.populate(query, [callback])` | ||
#### `rpc.populate(target, query, [callback])` | ||
@@ -65,0 +65,0 @@ Populate the `rpc.nodes` routing table with nodes discovered by looking for other peers close to our own local node id using the specified query. The internal routing table will be used for subsequent closest queries to take load of the bootstrap nodes. |
var krpc = require('./') | ||
var tape = require('tape') | ||
var Buffer = require('safe-buffer').Buffer | ||
@@ -56,3 +57,3 @@ tape('query + reply', function (t) { | ||
var replies = 2 | ||
var id = new Buffer('aaaabbbbccccddddeeeeaaaabbbbccccddddeeee', 'hex') | ||
var id = Buffer.from('aaaabbbbccccddddeeeeaaaabbbbccccddddeeee', 'hex') | ||
var client = krpc({ | ||
@@ -59,0 +60,0 @@ nodes: ['localhost:' + server.address().port] |
Sorry, the diff of this file is not supported yet
17586
387
4
+ Addedsafe-buffer@^5.1.1
Updatedk-rpc-socket@^1.7.0