Set of neighboors for the gossip protocol Cyclon
Builds on top of peer-set
const PeerSet = require('peer-set-cyclon')
const PeerInfo = require('peer-info')
const Alice = new PeerInfo()
const Bob = new PeerInfo()
const Charles = new PeerInfo()
const neighbors = new PeerSet([Alice, Bob], 3)
neighbors.updateAge()
// Alice.age == 1
// Bob.age == 1
neightbors.add([Charles])
neighbors.updateAge()
// Alice.age == 2
// Bob.age == 2
// Charles.age == 1
neighbors.oldest()
// Alice
const PeerSetCyclon = require('peer-set-cyclon')
See peer-set APIs.
Creates a set of peers with an array of peers, a max size and a function to get the peerId from a peer object. By default, peer objects are assumed to be PeerInfo.
Updates age of each peer by 1
Get the oldest peer in the set
MIT