anternet-peers-set
v0.1.1
Published
Anternet library for storing and sharing set of peers.
Downloads
7
Readme
anternet-peers-set.js
Anternet library for storing and sharing set of peers.
Example
const Anternet = require('anternet');
const Peer = require('anternet-peer');
const PeersSet = require('anternet-peers-set');
const address = '127.0.0.1';
const port = 12345;
const peer = new Peer(port, address);
const peersSet = new PeersSet();
peersSet.add(peer);
console.log(peersSet.has(peer)); // true
console.log(peersSet.size); // 1
// use with Anternet
const anternet = new Anternet();
PeersSet.extend(anternet);
// send peers on request
anternet.request(msgType, [peersSet], 123123, '127.0.0.1');
// send peers on response
anternet.response(rid, [peersSet], 123123, '127.0.0.1');
License
MIT License. Copyright © 2016 Moshe Simantov