{"id":22608931,"url":"https://github.com/bitfinexcom/grenache-nodejs-link","last_synced_at":"2025-04-11T06:14:11.349Z","repository":{"id":23965598,"uuid":"100271549","full_name":"bitfinexcom/grenache-nodejs-link","owner":"bitfinexcom","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-15T07:51:53.000Z","size":87,"stargazers_count":4,"open_issues_count":4,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T06:14:04.912Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfinexcom.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-14T13:38:27.000Z","updated_at":"2024-02-11T16:08:08.000Z","dependencies_parsed_at":"2024-06-18T22:48:10.109Z","dependency_job_id":null,"html_url":"https://github.com/bitfinexcom/grenache-nodejs-link","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fgrenache-nodejs-link","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fgrenache-nodejs-link/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fgrenache-nodejs-link/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fgrenache-nodejs-link/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfinexcom","download_url":"https://codeload.github.com/bitfinexcom/grenache-nodejs-link/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351393,"owners_count":21089270,"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-12-08T15:10:07.184Z","updated_at":"2025-04-11T06:14:11.297Z","avatar_url":"https://github.com/bitfinexcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grenache-nodejs-link\n\n\u003cimg src=\"logo.png\" width=\"15%\" /\u003e\n\nIn Grenache, `grenache-nodejs-link` communicates with the DHT.\n\n### Requirements\n\nInstall `Grenache Grape`: https://github.com/bitfinexcom/grenache-grape:\n\n```bash\nnpm i -g grenache-grape\n```\n\n```\n// Start 2 Grapes\ngrape --dp 20001 --aph 30001 --bn '127.0.0.1:20002'\ngrape --dp 20002 --aph 40001 --bn '127.0.0.1:20001'\n```\n\n### Class: Link\n\n#### new Link(options)\n\n - `options` \u0026lt;Object\u0026gt; Options for the link\n    - `grape` \u0026lt;String\u0026gt; Address of the Grenache Grape instance. Communication is done via WebSocket or HTTP.\n    - `requestTimeout` \u0026lt;Number\u0026gt; Default timeout for requests to Grape,\n    - `pingTimeout` \u0026lt;Number\u0026gt; Ping connection timeout to Grape (triggers reconnect attempt),\n    - `lruMaxSizeLookup` \u0026lt;Number\u0026gt; Maximum size of the cache,\n        checked by applying the length function to all values\n        in the cache\n    - `lruMaxAgeLookup` \u0026lt;Number\u0026gt; Maximum cache age in ms.\n\n#### link.start()\n\nSets up the link.\n\n#### link.stop()\n\nStops all current requests and announces.\n\n#### link.announce(name)\n\n  - `name` \u0026lt;String\u0026gt; Name of the service, used to find the service\n    from other peers\n\nUsed to announce a service, e.g. a [RPC Server](#class-peerrpcserver).\n\n#### link.startAnnouncing(name, port, [opts])\n\nKeep announcing a service every ~2min (default) or specify interval in `opts.interval`\n\n#### link.stopAnnouncing(name, port)\n\nStop announcing a service\n\n#### link.put(data, callback)\n\n  - `data`\n    - `v`: \u0026lt;String\u0026gt; value to store\n  - `callback` \u0026lt;function\u0026gt;\n\nPuts a value into the DHT.\n[Example](https://github.com/bitfinexcom/grenache-nodejs-link/blob/master/examples/put_get.js).\n\n#### link.get(hash | object, callback)\n\n  - `hash` \u0026lt;String\u0026gt; Hash used for lookup\n  - `object` \u0026lt;Object\u0026gt;\n    - `hash`: \u0026lt;String\u0026gt; Hash used for lookup\n    - `salt`: \u0026lt;String\u0026gt; (optional) salt that was used if data was stored with salt. Required in those cases.\n\n  - `callback` \u0026lt;function\u0026gt;\n\nRetrieves a stored value from the DHT via a `hash` \u0026lt;String\u0026gt;.\nIt also supports an object, which is used to pass a previously used salt in order to retrieve the data teh salt was used upon.\n\nCallback returns `err` \u0026lt;Object\u0026gt; and data \u0026lt;Object\u0026gt;.\n\n[Example](https://github.com/bitfinexcom/grenache-nodejs-link/blob/master/examples/put_get.js).\n\n\n#### link.lookup(name, [opts], callback)\n\n  - `name` \u0026lt;String\u0026gt; Name of the service to lookup\n  - `opts`\n    - `retry`: \u0026lt;Number\u0026gt; retry count\n  - `callback` \u0026lt;function\u0026gt;\n\nRetrieves the ports and IPs of a given service name.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fgrenache-nodejs-link","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfinexcom%2Fgrenache-nodejs-link","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fgrenache-nodejs-link/lists"}