{"id":19847824,"url":"https://github.com/mascrypt0/chordhelper","last_synced_at":"2026-05-14T09:34:48.484Z","repository":{"id":226446745,"uuid":"768739123","full_name":"mascrypt0/chordhelper","owner":"mascrypt0","description":"Chord Distributed Hash Table","archived":false,"fork":false,"pushed_at":"2024-03-08T15:46:51.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T16:02:52.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mascrypt0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-07T16:37:44.000Z","updated_at":"2024-03-07T16:44:16.000Z","dependencies_parsed_at":"2024-03-07T16:56:05.409Z","dependency_job_id":"179217d0-5037-4d50-85d8-1b22792e5d91","html_url":"https://github.com/mascrypt0/chordhelper","commit_stats":null,"previous_names":["mascrypt0/chordhelper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mascrypt0%2Fchordhelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mascrypt0%2Fchordhelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mascrypt0%2Fchordhelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mascrypt0%2Fchordhelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mascrypt0","download_url":"https://codeload.github.com/mascrypt0/chordhelper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241226809,"owners_count":19930487,"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-11-12T13:15:18.643Z","updated_at":"2026-05-14T09:34:48.449Z","avatar_url":"https://github.com/mascrypt0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Chord Distributed Hash Table\n============================\n\n[Chord](http://pdos.csail.mit.edu/papers/chord:sigcomm01/chord_sigcomm.pdf)\nis a self-organizing distributed hash table. This is an implementation of the Chord\nalgorithm in Node.js. It provides the ability to construct a Chord cluster and to\nroute application layer messages to a process responsible for a range of keys.\n\nIt supports virtual nodes and uses UDP as its out-of-process transport layer.\n\nAPI\n---\n\n### chord.hash(string)\n\nOccasionally, you may wish to hash a value the same way that Chord does. It currently\nuses Murmurhash3-128, but `hash` will always expose the current hash algorithm.\n\n### chord.Chord(listen_port, virtual_node_count, node_to_join, on_message)\n### chord.Chord(listen_port, virtual_node_count, on_message)\n\nThe primary entry point for starting a Chord server. The available arguments are:\n\n * `listen_port`: The UDP port on which to listen.\n * `virtual_node_count`: The number of virtual nodes to start.\n * `node_to_join`: The address of a node to join (optional).\n * `on_message`: A callback function that is notified when a message addressed to a\n   local virtual node is received.\n\nThe returned value is a `send_message` function. The `send_message` function also has a\n`close` property, which is a function to shut down the local virtual nodes.\n\n    var server = chord.Chord(...);  // start the server\n    server(...)                     // send a message (see below)\n    server.close()                  // stop the server\n\n### send_message(to, id, message, reply_to)\n\nThis is the function for sending a new application level message to another node in the\nChord ring. It takes the following parameters:\n\n * `to`: Optional (must be null if not used). The address of the node to which to send.\n * `id`: The key of the DHT to which to address the message. The node which is currently\n   responsible for that point in the hash ring will receive the message.\n * `message`: A JSON-able object, which will be send to the recipient.\n * `reply_to`: Optional. The address of the node for the recipient to reply to. This may be\n   used as a way to share the identity of a node with another node. If the recipient replies,\n   their message will be sent to the `reply_to` node. If no `reply_to` is specified, replies\n   return to the original sender.\n\n### chord.Client(on_message, listen_port)\n\nThe client is intended to provide an easy way to have non-members of the Chord ring\ncommunicate with members of the Chord ring. This is useful if, for example, members of the\nChord ring provide a data storage service, and clients of this data storage service need\nto make requests of it without themselves storing data.\n\nA client is really just a completely local Chord ring that never joins any other node. As such,\nit has all of the machinery necessary to speak the Chord wire protocol to another Chord ring.\n\n * `on_message`: The callback that is notified when a message is received.\n * `listen_port`: The port on which to listen for reply messages.\n\n### on_message(from, id, message, reply)\n\nWhenever a client or server receives a message, its `on_message` callback is triggered. The callback\nreceives a few parameters:\n\n * `from`: The address of the sender. There is a `from.id` property, which is the point in the hash\n   ring of the sender's identity.\n * `id`: The key to which the message was sent.\n * `message`: The application layer message that was received.\n * `reply`: A callback for sending a reply message (see below).\n\n### reply(message, to, reply_to)\n\nSend a message to source (or `reply_to`) of a received message.\n\n * `message`: The message to send back.\n * `to`: Optional. The address of the node to which to send the reply.\n * `reply_to`: Optional. The address to which the recipient will reply. If not specified,\n   any reply will return to the originator of the message. One useful pattern is to\n   pass `from` as the `reply_to`, which will cause the next reply to also go to the originator\n   of the request. This can permit multi-stage operations without having to route the final reply\n   through intermediate nodes.\n\nSetting up a cluster\n--------------------\nWhen you set up a cluster, you will first create an initial node. The only thing that\ndistinguishes your initial node from any other node is that it does not join any other\nnode. Subsequent nodes join any existing node. The Chord protocol will distribute the\nexistence of new nodes around the ring automatically.\n\nTo create a new node:\n\n    var chord = require('chord');\n    chord.Chord(1234,             // Listen on port 1234\n                10,               // Start 10 virtual nodes\n                on_message);      // Call the function 'on_message' when we receive something\n\nTo connect a subsequent node:\n\n    chord.Chord(1235,\n                10,\n                {address:'127.0.0.1', port:1234}, // Connect to the existing server on port 1234\n                on_message_2);                    // Provide a callback for receiving.\n\nAll 20 virtual nodes will talk amongst themselves to arrange themselves in a ring. Subsequent\nmessages will be delivered the node that owns a particular key at that time. Note that due to\nnodes leaving an joining, the node that owns a particular key may change over time. Your application\nshould be designed to expect this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmascrypt0%2Fchordhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmascrypt0%2Fchordhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmascrypt0%2Fchordhelper/lists"}