add README

This commit is contained in:
David Dias 2015-09-19 16:46:52 +01:00
parent 897e72ca14
commit f15b452d34
4 changed files with 97 additions and 2 deletions

View File

@ -1,2 +1,61 @@
# abstract-peer-routing
A test suite and interface you can use to implement a Peer Routing for libp2p.
abstract-peer-routing
=====================
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
> 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 abstract-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.
# Modules that implement the interface
- https://github.com/diasdavid/node-ipfs-kad-router
# Badge
Include this badge in your readme if you make a module that is compatible with the abstract-record-store API. You can validate this by running the tests.
![](https://raw.githubusercontent.com/diasdavid/abstract-peer-routing/master/img/badge.png)
# How to use the battery of tests
## Node.js
```
var tape = require('tape')
var tests = require('abstract-record-store/tests')
var YourPeerRouter = require('../src')
var common = {
setup: function (t, cb) {
cb(null, YourPeerRouter)
},
teardown: function (t, cb) {
cb()
}
}
tests(tape, common)
```
## Go
> WIP
# API
A valid (read: that follows this abstraction) stream muxer, must implement the following API.
### 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

22
package.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "abstract-peer-routing",
"version": "0.0.0",
"description": "A test suite and interface you can use to implement a Peer Routing for libp2p.",
"repository": {
"type": "git",
"url": "https://github.com/diasdavid/abstract-peer-routing.git"
},
"keywords": [
"IPFS"
],
"author": "David Dias <daviddias@ipfs.io>",
"license": "MIT",
"bugs": {
"url": "https://github.com/diasdavid/abstract-peer-routing/issues"
},
"homepage": "https://github.com/diasdavid/abstract-peer-routing",
"devDependencies": {},
"dependencies": {
"timed-tape": "^0.1.0"
}
}

8
tests/base-test.js Normal file
View File

@ -0,0 +1,8 @@
module.exports.all = function (test, common) {
test('a test', function (t) {
common.setup(test, function (err, pr) {
t.plan(1)
t.ifError(err)
})
})
}

6
tests/index.js Normal file
View 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)
}