0.2.4 • Published 8 years ago

peer-set-cyclon v0.2.4

Weekly downloads
11
License
MIT
Repository
github
Last release
8 years ago

peer-set-cyclon JavaScript implementation

Set of neighboors for the gossip protocol Cyclon

Builds on top of peer-set

Example

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

API

const PeerSetCyclon = require('peer-set-cyclon')

See peer-set APIs.

const set = new PeerSetCyclon(peers, {limit: number, peerToId: function)

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.

set.updateAge()

Updates age of each peer by 1

set.oldest()

Get the oldest peer in the set

License

MIT

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago