├── .gitignore
├── LICENSE
├── README.md
├── img
├── badge.png
├── badge.sketch
└── badge.svg
├── package.json
└── tests
├── base-test.js
└── index.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27 | node_modules
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 David Dias
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ⛔️ DEPRECATED: interface-peer-routing is now included in [libp2p-interfaces](https://github.com/libp2p/js-interfaces)
2 | ======
3 |
4 | # interface-peer-routing
5 |
6 | [](http://protocol.ai)
7 | [](http://libp2p.io/)
8 | [](http://webchat.freenode.net/?channels=%23libp2p)
9 | [](https://discuss.libp2p.io)
10 | [](https://github.com/feross/standard)
11 |
12 | > A test suite and interface you can use to implement a Peer Routing module for libp2p.
13 |
14 | The primary goal of this module is to enable developers to pick and swap their Peer Routing module as they see fit for their libp2p installation, without having to go through shims or compatibility issues. This module and test suite were heavily inspired by abstract-blob-store and interface-stream-muxer.
15 |
16 | Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite.
17 |
18 | The API is presented with both Node.js and Go primitives, however, there is not actual limitations for it to be extended for any other language, pushing forward the cross compatibility and interop through diferent stacks.
19 |
20 | ## Lead Maintainer
21 |
22 | [Vasco Santos](https://github.com/vasco-santos).
23 |
24 | # Modules that implement the interface
25 |
26 | - [JavaScript libp2p-kad-dht](https://github.com/libp2p/js-libp2p-kad-dht)
27 | - [JavaScript libp2p-delegated-peer-routing](https://github.com/libp2p/js-libp2p-delegated-peer-routing)
28 | - [JavaScript libp2p-kad-routing](https://github.com/libp2p/js-libp2p-kad-routing)
29 |
30 | # Badge
31 |
32 | Include this badge in your readme if you make a module that is compatible with the interface-record-store API. You can validate this by running the tests.
33 |
34 | 
35 |
36 | # How to use the battery of tests
37 |
38 | ## Node.js
39 |
40 | ```javascript
41 | var tape = require('tape')
42 | var tests = require('interface-peer-routing/tests')
43 | var YourPeerRouter = require('../src')
44 |
45 | var common = {
46 | setup: function (t, cb) {
47 | cb(null, YourPeerRouter)
48 | },
49 | teardown: function (t, cb) {
50 | cb()
51 | }
52 | }
53 |
54 | tests(tape, common)
55 | ```
56 |
57 | ## Go
58 |
59 | > WIP - The go-libp2p implementation does not have a test suite to be used, yet.
60 |
61 | # API
62 |
63 | A valid (read: that follows this abstraction) Peer Routing module must implement the following API.
64 |
65 | ### `.findPeers` - Find peers 'responsible' or 'closest' to a given key
66 |
67 | - `Node.js` peerRouting.findPeers(key, function (err, peersPriorityQueue) {})
68 |
69 | In a peer to peer context, the concept of 'responsability' or 'closeness' for a given key translates to having a way to find deterministically or that at least there is a significant overlap between searches, the same group of peers when searching for the same given key.
70 |
71 | This method will query the network (route it) and return a Priority Queue datastructe with a list of PeerInfo objects, ordered by 'closeness'.
72 |
73 | key is a multihash
74 |
--------------------------------------------------------------------------------
/img/badge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/libp2p/interface-peer-routing/361257d65dd74c12013deac12bf79e980d30f527/img/badge.png
--------------------------------------------------------------------------------
/img/badge.sketch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/libp2p/interface-peer-routing/361257d65dd74c12013deac12bf79e980d30f527/img/badge.sketch
--------------------------------------------------------------------------------
/img/badge.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "interface-peer-routing",
3 | "version": "0.1.3",
4 | "description": "A test suite and interface you can use to implement a Peer Routing for libp2p.",
5 | "leadMaintainer": "Vasco Santos ",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/diasdavid/interface-peer-routing.git"
9 | },
10 | "keywords": [
11 | "IPFS"
12 | ],
13 | "author": "David Dias ",
14 | "license": "MIT",
15 | "bugs": {
16 | "url": "https://github.com/diasdavid/interface-peer-routing/issues"
17 | },
18 | "homepage": "https://github.com/diasdavid/interface-peer-routing",
19 | "devDependencies": {},
20 | "dependencies": {
21 | "peer-id": "~0.12.2",
22 | "timed-tape": "^0.1.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/base-test.js:
--------------------------------------------------------------------------------
1 | var Id = require('peer-id')
2 |
3 | module.exports.all = function (test, common) {
4 | test('Simple findPeers test', function (t) {
5 | common.setup(test, function (err, pr) {
6 | t.plan(3)
7 | t.ifError(err)
8 | pr.findPeers(Id.create().toBytes(), function (err, peerQueue) {
9 | t.ifError(err)
10 | t.equal(peerQueue.length >= 1, true)
11 | common.teardown()
12 | })
13 | })
14 | })
15 | }
16 |
--------------------------------------------------------------------------------
/tests/index.js:
--------------------------------------------------------------------------------
1 | var timed = require('timed-tape')
2 |
3 | module.exports = function (test, common) {
4 | test = timed(test)
5 | require('./base-test.js').all(test, common)
6 | }
7 |
--------------------------------------------------------------------------------