-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from libp2p/feat/0.1
v0.1
- Loading branch information
Showing
22 changed files
with
1,107 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
**/node_modules/ | ||
**/*.log | ||
test/repo-tests* | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
||
coverage | ||
|
||
# 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 | ||
|
||
build | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- 4 | ||
- 5 | ||
- stable | ||
|
||
# Make sure we have new NPM. | ||
before_install: | ||
- npm install -g npm | ||
|
||
script: | ||
- npm run lint | ||
- npm test | ||
- npm run coverage | ||
|
||
|
||
before_script: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
|
||
after_success: | ||
- npm run coverage-publish | ||
|
||
env: | ||
- CXX=g++-4.8 | ||
|
||
addons: | ||
firefox: 'latest' | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- g++-4.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
machine: | ||
node: | ||
version: stable | ||
|
||
dependencies: | ||
pre: | ||
- google-chrome --version | ||
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | ||
- sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | ||
- sudo apt-get update | ||
- sudo apt-get --only-upgrade install google-chrome-stable | ||
- google-chrome --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict' | ||
|
||
const PeerId = require('peer-id') | ||
const PeerInfo = require('peer-info') | ||
const multiaddr = require('multiaddr') | ||
const libp2pIPFS = require('libp2p-ipfs') | ||
const PSG = require('../../src') | ||
const series = require('run-series') | ||
|
||
const privateKey = 'CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJD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IJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw==' | ||
|
||
let nodePublisher | ||
let psPublisher | ||
|
||
function bootNode (next) { | ||
const idPublisher = PeerId.createFromPrivKey(privateKey) | ||
const peerPublisher = new PeerInfo(idPublisher) | ||
peerPublisher.multiaddr.add(multiaddr('/ip4/0.0.0.0/tcp/12345')) | ||
nodePublisher = new libp2pIPFS.Node(peerPublisher) | ||
nodePublisher.start((err) => { | ||
console.log('Publisher listening on:') | ||
|
||
peerPublisher.multiaddrs.forEach((ma) => { | ||
console.log(ma.toString() + '/ipfs/' + idPublisher.toB58String()) | ||
}) | ||
next(err) | ||
}) | ||
} | ||
|
||
function setUpPS (next) { | ||
console.log('attaching pubsub') | ||
psPublisher = new PSG(nodePublisher) | ||
next() | ||
} | ||
|
||
function publishMsg (err) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
setInterval(() => { | ||
process.stdout.write('.') | ||
psPublisher.publish('interop', new Buffer('hey, how is it going?')) | ||
}, 300) | ||
} | ||
|
||
series([ | ||
bootNode, | ||
setUpPS | ||
], publishMsg) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
'use strict' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict' | ||
|
||
const gulp = require('gulp') | ||
|
||
require('aegir/gulp')(gulp) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
All subscribe to Partial | ||
the same topic subscriptions | ||
|
||
line line | ||
◉────◉────◉ ◉────◎────◉ | ||
a b c a b c | ||
|
||
|
||
1 level tree 1 level tree | ||
┌◉┐ ┌◉┐ | ||
│b│ │b│ | ||
◉─┘ └─◉ ◎─┘ └─◉ | ||
a c a c | ||
|
||
2 levels tree 2 levels tree | ||
┌◉┐ ┌◉┐ | ||
│c│ │c│ | ||
┌◉─┘ └─◉┐ ┌◎─┘ └─◉┐ | ||
│b d│ │b d│ | ||
◉─┘ └─◉ ◉─┘ └─◎ | ||
a e a e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"name": "libp2p-floodsub", | ||
"version": "0.0.0", | ||
"description": "libp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).", | ||
"main": "lib/core/index.js", | ||
"jsnext:main": "src/core/index.js", | ||
"scripts": { | ||
"lint": "aegir-lint", | ||
"coverage": "gulp coverage", | ||
"test": "PHANTOM=off gulp test", | ||
"test:node": "gulp test:node", | ||
"test:node:core": "TEST=core npm run test:node", | ||
"test:node:http": "TEST=http npm run test:node", | ||
"test:node:cli": "TEST=cli npm run test:node", | ||
"test:browser": "PHANTOM=off gulp test:browser", | ||
"build": "gulp build", | ||
"release": "PHANTOM=off gulp release", | ||
"release-minor": "PHANTOM=off gulp release --type minor", | ||
"release-major": "PHANTOM=off gulp release --type major", | ||
"coverage-publish": "aegir-coverage publish" | ||
}, | ||
"pre-commit": [ | ||
"lint", | ||
"test" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/libp2p/js-libp2p-floodsub.git" | ||
}, | ||
"keywords": [ | ||
"IPFS", | ||
"libp2p", | ||
"pubsub", | ||
"gossip", | ||
"flood", | ||
"flooding" | ||
], | ||
"author": "David Dias <daviddias@ipfs.io>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/libp2p/js-libp2p-floodsub/issues" | ||
}, | ||
"homepage": "https://github.com/libp2p/js-libp2p-floodsub#readme", | ||
"devDependencies": { | ||
"aegir": "^8.0.1", | ||
"chai": "^3.5.0", | ||
"libp2p-ipfs": "^0.14.1", | ||
"lodash.times": "^4.3.2", | ||
"multiaddr": "^2.0.3", | ||
"peer-id": "^0.7.0", | ||
"peer-info": "^0.7.1", | ||
"pre-commit": "^1.1.3", | ||
"run-parallel": "^1.1.6", | ||
"run-series": "^1.1.4" | ||
}, | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"git-sha1": "^0.1.2", | ||
"length-prefixed-stream": "^1.5.0", | ||
"lodash.intersection": "^4.4.0", | ||
"lodash.uniq": "^4.5.0", | ||
"lodash.values": "^4.3.0", | ||
"time-cache": "^0.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict' | ||
|
||
const debug = require('debug') | ||
|
||
const log = debug('libp2p:floodsub') | ||
log.err = debug('libp2p:floodsub:error') | ||
|
||
module.exports = { | ||
log: log, | ||
multicodec: '/floodsub/1.0.0' | ||
} |
Oops, something went wrong.