Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor, Mock API, more tests #1

Merged
merged 7 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/orbit-db
/orbit-db
/coverage
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
language: node_js
language: node_js
node_js:
- "8"
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

This is a work in progress implementation of the IPFS integration of [Chlu](https://chlu.io).

See [CONTRIBUTING.md](https://github.com/ChluNetwork/chlu-ipfs-support/blob/master/CONTRIBUTING.md) to hack on the code.

## Usage

See [CONTRIBUTING.md](https://github.com/ChluNetwork/chlu-ipfs-support/blob/master/CONTRIBUTING.md)
__Note__: this has only been tested in Node but is supposed to work in the browser using Webpack. Please check out the js-ipfs information about running in the browser through Webpack for additional information.

This module has not been release to NPM yet. You can however install it and import/require it, but it's still WIP. Check out [index.js](https://github.com/ChluNetwork/chlu-ipfs-support/blob/master/src/index.js) to see the available API calls, and the tests for examples.

You can install this module globally and use `chlu-service-node` to run a Chlu Service Node.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fazo96 why do we need this to be installed globally? Can't one install it in a local folder and then run it with the required permissions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also be installed locally: in any folder, run npm install chlu-ipfs-support. The binary should be available under ./node_modules/chlu-ipfs-support/bin/ like any other npm module.

This binary just starts ChluIPFS and its service node routines for now, there are still a lot of improvements to make and tests to run


If you are in development mode, you can pass an option `mock: true` when initializing the class to get a fake API that returns example data.

### Undocumented differences from the protocol

This is a collection of features and design choices not compatible with the Chlu Protocol. They exist to allow this to work before the protocol is finalized.

Chlu Support Nodes:

- chlu support nodes listen for chlu events and take actions to help the stability of the network. The events are written into the pubsub-room "chlu-experimental"
- currently they react to review updates by pinning the review
- they will replicate OrbitDBs for customer review updates

Writing Reviews:

- when a review is written, the API will not return until a service node has replied saying it successfully pinned the review

Updating Reviews:

- this is not implemented yet but it will make use of an OrbitDB feed
10 changes: 4 additions & 6 deletions src/chlu-service-node.js → bin/chlu-service-node.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#!/usr/bin/env node
const ChluIPFS = require('./index.js');
const ChluIPFS = require('../src/index.js');

let serviceNode = null;

async function main(){
serviceNode = new ChluIPFS({ type: ChluIPFS.types.service });
console.log('Creating Chlu Experimental Service Node');
console.log('Starting Chlu IPFS');
console.log('Starting Chlu IPFS Service Node');
await serviceNode.start();
console.log('Starting Service Node');
await serviceNode.runServiceNode();

serviceNode.room.on('peer joined', (peer) => {
serviceNode.instance.room.on('peer joined', (peer) => {
console.log('Peer joined the room', peer);
});

serviceNode.room.on('peer left', (peer) => {
serviceNode.instance.room.on('peer left', (peer) => {
console.log('Peer left...', peer);
});
}
Expand Down
138 changes: 136 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
"scripts": {
"test": "jest",
"test-watch": "jest --watch",
"lint": "eslint src"
"test-coverage": "jest --coverage",
"lint": "eslint src tests bin"
},
"bin": {
"chlu-service-node": "src/chlu-service-node.js"
"chlu-service-node": "bin/chlu-service-node.js"
},
"author": "Enrico Fasoli (fazo96)",
"license": "MIT",
"dependencies": {
"ipfs": "~0.27.0",
"ipfs-pubsub-room": "~1.0.1",
"orbit-db": "~0.18.0"
"orbit-db": "~0.18.0",
"winston": "^3.0.0-rc1"
},
"devDependencies": {
"eslint": "^4.12.0",
Expand All @@ -37,8 +39,18 @@
"jest": true
},
"rules": {
"quotes": 0,
"no-console": 1,
"indent": [
"error",
4
],
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"no-console": 0,
"no-debugger": 1,
"no-var": 1,
"semi": [
Expand Down
Loading