-
Notifications
You must be signed in to change notification settings - Fork 10
dWeb DHT Peer Codec
Jared Rice Sr edited this page Jul 1, 2018
·
4 revisions
A dWeb compliant encoder for encoding a list of IPV4 peers to buffers.
npm install @dwdht/peers
var dWebCodec = require('@dwdht/peers')
var dWebBuffer = dWebCodec.encode([{
host: '127.0.0.1',
port: 8080
}, {
host: '127.0.0.1',
port: 9090
}])
console.log(dWebBuffer) // 12 byte buffer
console.log(dWebCodec.decode(buf)) // the peer list
Encode a list of IPV4 peers into a buffer.
Decode a buffer into a list of peers.
Returns the amount of bytes needed to encode the peers into a buffer
Create a new @dwdht/peers
decoder that encodes/decodes a fixed size peerId
in addition to host/port. The peerId
is exposed as the .id
property on a peer object.