{"id":13483074,"url":"https://github.com/nicola/js-gossip-cyclon","last_synced_at":"2025-10-07T03:38:01.451Z","repository":{"id":57252569,"uuid":"56527775","full_name":"nicola/js-gossip-cyclon","owner":"nicola","description":":family: Cyclon Gossip: (P2P membership management) in Javascript","archived":false,"fork":false,"pushed_at":"2016-05-17T04:55:45.000Z","size":602,"stargazers_count":46,"open_issues_count":3,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-08T23:46:05.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicola.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-18T17:29:08.000Z","updated_at":"2025-02-07T20:52:01.000Z","dependencies_parsed_at":"2022-08-31T22:21:08.681Z","dependency_job_id":null,"html_url":"https://github.com/nicola/js-gossip-cyclon","commit_stats":null,"previous_names":["nicola/gossip-cyclon"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicola%2Fjs-gossip-cyclon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicola%2Fjs-gossip-cyclon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicola%2Fjs-gossip-cyclon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicola%2Fjs-gossip-cyclon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicola","download_url":"https://codeload.github.com/nicola/js-gossip-cyclon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251343849,"owners_count":21574438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:08.043Z","updated_at":"2025-10-07T03:37:56.426Z","avatar_url":"https://github.com/nicola.png","language":"JavaScript","funding_links":[],"categories":["Modules"],"sub_categories":[],"readme":"# Gossip: Cyclon in Javascript\n\n##### Attention: this is work in progress and things may break!\n\n[![Build Status](https://travis-ci.org/nicola/js-gossip-cyclon.svg?style=flat-square)](https://travis-ci.org/nicola/js-gossip-cyclon)\n\nThis implements the Cyclon gossip protocol [1] for membership management.\n\n##### Gossip in _simple language_\n\nImagine you have big group of people and you want to tell everybody something. You could _broadcast_ a message by talking to each of them individually, or you could just talk to some (this is called gossip), telling them to tell other people.\n\n![Gossip protocols by Virginia Alonso](https://github.com/nicola/js-gossip-cyclon/blob/master/cartoon.png)\n\n\u003e Illustration by [@virginialonso](https://github.com/virginialonso)\n\n##### Cyclon in _simple language_\n\nCyclon is a simple gossip protocol that ensures that every peer in the network gets connected with the network of peers, without being connected to every single one. This is done by peers keeping a list of neighbors (small compared to the network) and at every interval, ask the neighbor that has been the longest in a peer list of neighbors (this is called partial view), to exchange some neighbors.\n\n\n## Cyclon\n\n```js\nconst CyclonPeer = require('gossip-cyclon')\nconst parallel = require('run-parallel')\n\nconst Alice = new CyclonPeer()\nconst Bob = new CyclonPeer()\n\nAlice.addPeers([Bob.me])\n\nparallel([\n  () =\u003e Alice.listen()\n  () =\u003e Bob.listen()\n], (err) =\u003e {\n  if (!err) {\n    Alice.start()\n    Bob.start()\n    // This will make Alice and Bob exchange each others information every 1 second\n  }\n})\n\n```\n\n## Run the visualization\n\nTo help understand the protocol, I wrote a visualization that you can run with the following instructions.\nYou can add new peers or click on existing peers to trigger a shuffle. Find the rest of the code [here](https://github.com/nicola/js-gossip-cyclon/tree/master/viz)\n\n```bash\n$ git clone https://github.com/nicola/js-gossip-cyclon\n$ cd js-gossip-cyclon\n$ npm install\n$ node viz/index.js\n// Now visit http://127.0.0.1:8080\n```\n\n\u003cimg src=\"https://raw.githubusercontent.com/nicola/js-gossip-cyclon/master/simulation.png\" width=\"500px\"\u003e\n\n\n## Usage\n\n### constructor\n\n#### `var peer = new CyclonPeer(opts)`\n\n`opts` can have:\n- `peer`: [PeerInfo](http://npm.im/peer-info) object of this CyclonPeer, default: `new PeerInfo()`.\n- `maxShuffle`: how many peers to send during shuffling\n- `maxPeers`: how many peers can be stored in the list of neighboors (or `.partialView`)\n- `interval`: how often CyclonPeer should shuffle\n- `peers`: array of peers to bootstrap CyclonPeer (they will be added to its `.partialView`)\n\n### variables\n\n#### `peer.partialView`\n\nPartial view of the peer, this is a [PeerSet](https://github.com/nicola/js-peer-set-cyclon)\n\n#### `peer.peer`\n\nThe current peer object, by default a [PeerInfo](http://npm.im/peer-info)\n\n### methods\n\n#### `peer.listen(cb)`\n\nListen on its transports (by default TCP)\n\n#### `peer.close(cb)`\n\nClose any listener on any transport\n\n#### `peer.start()`\n\nStart shuffling every `peer.interval`\n\n#### `peer.stop()`\n\nStops the repeating shuffling\n\n#### `peer.shuffle(cb)`\n\nShuffle and when done calls `cb` (on failure or success)\n\n#### `peer.addPeers(peers, replace)`\n\nAdd a list of peers, if the peers to be added will make `.partialView` grow beyond `.maxPeers`, the `replace` list will be used, otherwise drop 'em.\n\n#### `peer.updateAge()`\n\nUpdate the age of the peers in the `.partialView`\n\n## References\n\n[1] S. Voulgaris, D. Gavidia, M. van Steen. [CYCLON: Inexpensive Membership Management for Unstructured P2P Overlays](http://gossple2.irisa.fr/~akermarr/cyclon.jnsm.pdf). J. Network Syst. Manage. 13(2): 197-217 (2005)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicola%2Fjs-gossip-cyclon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicola%2Fjs-gossip-cyclon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicola%2Fjs-gossip-cyclon/lists"}