mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-03-16 13:50:50 +00:00
Merge branch 'master' of https://github.com/libp2p/interface-peer-routing into remote/connection
This commit is contained in:
commit
a2f6d92551
27
.gitignore
vendored
Normal file
27
.gitignore
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||
node_modules
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 David Dias
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
71
README.md
Normal file
71
README.md
Normal file
@ -0,0 +1,71 @@
|
||||
interface-peer-routing
|
||||
=====================
|
||||
|
||||
[](http://protocol.ai)
|
||||
[](http://libp2p.io/)
|
||||
[](http://webchat.freenode.net/?channels=%23libp2p)
|
||||
[](https://discuss.libp2p.io)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
> A test suite and interface you can use to implement a Peer Routing module for libp2p.
|
||||
|
||||
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.
|
||||
|
||||
Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite.
|
||||
|
||||
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.
|
||||
|
||||
## Lead Maintainer
|
||||
|
||||
[Vasco Santos](https://github.com/vasco-santos).
|
||||
|
||||
# Modules that implement the interface
|
||||
|
||||
- [JavaScript libp2p-kad-dht](https://github.com/libp2p/js-libp2p-kad-dht)
|
||||
- [JavaScript libp2p-delegated-peer-routing](https://github.com/libp2p/js-libp2p-delegated-peer-routing)
|
||||
- [JavaScript libp2p-kad-routing](https://github.com/libp2p/js-libp2p-kad-routing)
|
||||
|
||||
# Badge
|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
# How to use the battery of tests
|
||||
|
||||
## Node.js
|
||||
|
||||
```javascript
|
||||
var tape = require('tape')
|
||||
var tests = require('interface-peer-routing/tests')
|
||||
var YourPeerRouter = require('../src')
|
||||
|
||||
var common = {
|
||||
setup: function (t, cb) {
|
||||
cb(null, YourPeerRouter)
|
||||
},
|
||||
teardown: function (t, cb) {
|
||||
cb()
|
||||
}
|
||||
}
|
||||
|
||||
tests(tape, common)
|
||||
```
|
||||
|
||||
## Go
|
||||
|
||||
> WIP - The go-libp2p implementation does not have a test suite to be used, yet.
|
||||
|
||||
# API
|
||||
|
||||
A valid (read: that follows this abstraction) Peer Routing module must implement the following API.
|
||||
|
||||
### `.findPeers` - Find peers 'responsible' or 'closest' to a given key
|
||||
|
||||
- `Node.js` peerRouting.findPeers(key, function (err, peersPriorityQueue) {})
|
||||
|
||||
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.
|
||||
|
||||
This method will query the network (route it) and return a Priority Queue datastructe with a list of PeerInfo objects, ordered by 'closeness'.
|
||||
|
||||
key is a multihash
|
BIN
img/badge.png
Normal file
BIN
img/badge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
BIN
img/badge.sketch
Normal file
BIN
img/badge.sketch
Normal file
Binary file not shown.
19
img/badge.svg
Normal file
19
img/badge.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 133 KiB |
24
package.json
Normal file
24
package.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "interface-peer-routing",
|
||||
"version": "0.1.3",
|
||||
"description": "A test suite and interface you can use to implement a Peer Routing for libp2p.",
|
||||
"leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/diasdavid/interface-peer-routing.git"
|
||||
},
|
||||
"keywords": [
|
||||
"IPFS"
|
||||
],
|
||||
"author": "David Dias <daviddias@ipfs.io>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/diasdavid/interface-peer-routing/issues"
|
||||
},
|
||||
"homepage": "https://github.com/diasdavid/interface-peer-routing",
|
||||
"devDependencies": {},
|
||||
"dependencies": {
|
||||
"peer-id": "~0.12.2",
|
||||
"timed-tape": "^0.1.1"
|
||||
}
|
||||
}
|
15
tests/base-test.js
Normal file
15
tests/base-test.js
Normal file
@ -0,0 +1,15 @@
|
||||
var Id = require('peer-id')
|
||||
|
||||
module.exports.all = function (test, common) {
|
||||
test('Simple findPeers test', function (t) {
|
||||
common.setup(test, function (err, pr) {
|
||||
t.plan(3)
|
||||
t.ifError(err)
|
||||
pr.findPeers(Id.create().toBytes(), function (err, peerQueue) {
|
||||
t.ifError(err)
|
||||
t.equal(peerQueue.length >= 1, true)
|
||||
common.teardown()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
6
tests/index.js
Normal file
6
tests/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
var timed = require('timed-tape')
|
||||
|
||||
module.exports = function (test, common) {
|
||||
test = timed(test)
|
||||
require('./base-test.js').all(test, common)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user