{"id":18892376,"url":"https://github.com/hf/siddhartha","last_synced_at":"2025-07-04T00:05:20.423Z","repository":{"id":33902563,"uuid":"37617815","full_name":"hf/siddhartha","owner":"hf","description":"A simple, toy DHT written in Scala with Akka.","archived":false,"fork":false,"pushed_at":"2015-06-19T10:03:54.000Z","size":164,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-04T00:03:56.278Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/hf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-17T20:01:57.000Z","updated_at":"2025-04-04T22:23:28.000Z","dependencies_parsed_at":"2022-09-02T13:51:07.910Z","dependency_job_id":null,"html_url":"https://github.com/hf/siddhartha","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hf/siddhartha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fsiddhartha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fsiddhartha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fsiddhartha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fsiddhartha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hf","download_url":"https://codeload.github.com/hf/siddhartha/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fsiddhartha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421912,"owners_count":23464047,"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-08T08:01:39.822Z","updated_at":"2025-07-04T00:05:20.389Z","avatar_url":"https://github.com/hf.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Siddhartha\n\nSiddhartha is a simple, toy [DHT](https://en.wikipedia.org/wiki/Distributed_hash_table)\nwritten in [Scala](http://www.scala-lang.org/) with \n[Akka](http://akka.io).\n\n## Technical\n\n### Key Space Distribution\n\nThis DHT uses a binary-tree type key space distribution algorithm, as\nillustrated below:\n\n```\n1. -\u003e node(0) = [0, 200)  -- the top level node\n\n2.    node(0) = [0, 100),\n   -\u003e node(1) = [100, 200)\n\n3.    node(0) = [0, 100)\n      node(1) = [100, 150)\n      node(2) = [150, 200)\n\n  ...\n```\n\nThe `-\u003e` signifies where a new node attaches.\n\n#### Forwarding\n\nIf a node receives a request for a key `k` which is not in its key space `[a, b)`,\nit forwards the message to:\n\n- if `k \u003e= b` to the child whose `k \u003e= a(c)` (there is only one such child)\n- if `k \u003c a` to its parent\n\n## Usage\n\nFirstly, there are two main classes you should be concerned about:\n\n1. `Dharma` is the 'system' class. It wraps around `ActorSystem` and manages\n a local DHT system. It does not have to be a remotely accessible system.\n\n    - Each `Dharma` must have a `buddha`-named actor which is responsible for\n    managing the Siddhartha instances and their properties. It can also be used\n    for finding the Siddhartha's in a `Dharma`.\n\n2. `SiddharthaMap` is a Map-like interface for the DHT. It requires finding out\n a `Siddhartha`-type `ActorRef` from a `Dharma` and it routes all messages\n towards it.\n\n```scala\nval dharma = Dharma()\n\n// top level siddhartha that manages the whole keyspace\nval sdh = dharma.createSiddhartha((Keyspace.min, Keyspace.max))\n\nval map = SiddharthaMap(sdh)\n\n// these are all futures\nmap.put(Bytes(0, 1, 2, 3), Bytes(0, 1, 2, 3))\nmap.get(Bytes(0, 1, 2, 3))\nmap.remove(Bytes(0, 1, 2, 3)\n\n// child siddhartha, manages half of sdh's keyspace\nval childSdh = dharma.createSiddhartha(sdh)\n```\n\n### Remoting\n\nRead about [Akka remoting](http://doc.akka.io/docs/akka/2.2.3/scala/remoting.html)\nif you want to use the system as a true P2P DHT.\n\n*Remember:* Create Siddhartha's on the local `Dharma` but with remote `ActorRef`'s.\n\n## License\n\nThis project is Copyright (c) 2015 Stojan Dimitrovski, except where otherwise\nnoted.\n\nSee the accompanying file `LICENSE.txt` for the full legal text.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhf%2Fsiddhartha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhf%2Fsiddhartha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhf%2Fsiddhartha/lists"}