Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shikhars371 committed Jun 26, 2020
1 parent 291002c commit 7a6939a
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 68 deletions.
1 change: 1 addition & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copyright 2020 PeepsLabs
2 changes: 1 addition & 1 deletion collaborators.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Collaborators

hyperdrive-archive-swarm is only possible due to the excellent work of the following collaborators:
dwebfs-archive-swarm is only possible due to the excellent work of the following collaborators:

<table><tbody><tr><th align="left">juliangruber</th><td><a href="https://github.com/juliangruber">GitHub/juliangruber</a></td></tr>
<tr><th align="left">karissa</th><td><a href="https://github.com/karissa">GitHub/karissa</a></td></tr>
Expand Down
6 changes: 3 additions & 3 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var hyperdrive = require('hyperdrive')
var dwebfs = require('dwebfs')
var ram = require('random-access-memory')
var swarm = require('.')
var Buffer = require('safe-buffer').Buffer

var key = process.argv[2] && new Buffer(process.argv[2], 'hex')
var archive = hyperdrive(ram, key)
var archive = dwebfs(ram, key)
archive.ready(function (err) {
if (err) throw err
console.log('key', archive.key.toString('hex'))
var sw = swarm(archive)
sw.on('connection', function (peer, type) {
console.log('got', peer, type) // type is 'webrtc-swarm' or 'discovery-swarm'
console.log('got', peer, type) // type is 'webrtc-swarm' or 'dweb-discovery-swarm'
console.log('connected to', sw.connections, 'peers')
peer.on('close', function () {
console.log('peer disconnected')
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var swarmDefaults = require('dat-swarm-defaults')
var disc = require('discovery-swarm')
var swarmDefaults = require('dweb-swarm-defaults')
var disc = require('dweb-discovery-swarm')
var xtend = require('xtend')

module.exports = HyperdriveSwarm
Expand All @@ -17,12 +17,12 @@ function HyperdriveSwarm (archive, opts) {
var isHyperdbInstance = !!(archive.get && archive.put && archive.replicate && archive.authorize)

if (isHyperdbInstance && !archive.local) {
throw new Error('hyperdiscovery swarm must be created after the local hyperdb instance is ready!')
throw new Error('dweb-discovery swarm must be created after the local dappdb instance is ready!')
}

// Discovery Swarm Options
opts = xtend({
port: 3282,
port: 6620,
id: isHyperdbInstance ? archive.local.id.toString('hex') : archive.id,
hash: false,
stream: function (peer) {
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/karissa/hyperdiscovery.git"
"url": "git+https://github.com/karissa/dweb-discovery.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/karissa/hyperdiscovery/issues"
"url": "https://github.com/karissa/dweb-discovery/issues"
},
"homepage": "https://github.com/karissa/hyperdiscovery#readme",
"homepage": "https://github.com/karissa/dweb-discovery#readme",
"dependencies": {
"dweb-swarm-defaults": "^1.0.0",
"dweb-discovery-swarm": "^1.0.0",
Expand All @@ -24,7 +24,7 @@
},
"devDependencies": {
"dependency-check": "^3.1.0",
"hypercore": "^6.14.0",
"ddatabase": "^1.3.0",
"dappdb": "^1.0.0",
"dwebfs": "^1.1.0",
"random-access-memory": "^3.0.0",
Expand Down
52 changes: 26 additions & 26 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# hyperdiscovery
# dweb-discovery

[![build status](https://travis-ci.org/karissa/hyperdiscovery.svg?branch=master)](http://travis-ci.org/karissa/hyperdiscovery)
[![build status](https://travis-ci.org/karissa/dweb-discovery.svg?branch=master)](http://travis-ci.org/karissa/dweb-discovery)

Join the p2p swarm for [hypercore][core], [hyperdrive][drive], and [hyperdb][db] feeds. Uses
[discovery-swarm][swarm] under the hood.
Join the p2p swarm for [ddatabase][core], [dwebfs][drive], and [dappdb][db] feeds. Uses
[dweb-discovery-swarm][swarm] under the hood.

```
npm install hyperdiscovery
npm install dweb-discovery
```

## Usage

Run the following code in two different places and they will replicate the contents of the given `ARCHIVE_KEY`.

```js
var hyperdrive = require('hyperdrive')
var swarm = require('hyperdiscovery')
var dwebfs = require('dwebfs')
var swarm = require('dweb-discovery')

var archive = hyperdrive('./database', 'ARCHIVE_KEY')
var archive = dwebfs('./database', 'ARCHIVE_KEY')
var sw = swarm(archive)
sw.on('connection', function (peer, type) {
console.log('got', peer, type)
Expand All @@ -28,31 +28,31 @@ sw.on('connection', function (peer, type) {
})
```

Will use `discovery-swarm` to attempt to connect peers. Uses `datland-swarm-defaults` for peer introduction defaults on the server side, which can be overwritten (see below).
Will use `dweb-discovery-swarm` to attempt to connect peers. Uses `datland-swarm-defaults` for peer introduction defaults on the server side, which can be overwritten (see below).

The module can also create and join a swarm for a hypercore feed:
The module can also create and join a swarm for a ddatabase feed:

```js
var hypercore = require('hypercore')
var swarm = require('hyperdiscovery')
var ddatabase = require('ddatabase')
var swarm = require('dweb-discovery')

var feed = hypercore('/feed')
var feed = ddatabase('/feed')
var sw = swarm(feed)
```

The module can also create and join a swarm for a hyperdb feed:
The module can also create and join a swarm for a dappdb feed:

```js
var hyperdb = require('hyperdb')
var swarm = require('hyperdiscovery')
var dappdb = require('dappdb')
var swarm = require('dweb-discovery')

var db = hyperdb('/feed', 'ARCHIVE_KEY')
var db = dappdb('/feed', 'ARCHIVE_KEY')
db.on('ready', function() {
var sw = swarm(db)
})
```

A hyperdb database must be ready before attempting to connect to the swarm. When `download` is enabled the swarm will automatically `db.authorize()` all connecting peers.
A dappdb database must be ready before attempting to connect to the swarm. When `download` is enabled the swarm will automatically `db.authorize()` all connecting peers.

## API

Expand Down Expand Up @@ -84,15 +84,15 @@ Defaults from datland-swarm-defaults can also be overwritten:
* `dht.bootstrap`: distributed hash table bootstrapping nodes

## See Also
- [mafintosh/hypercore][core]
- [mafintosh/hyperdrive][drive]
- [mafintosh/hyperdb][db]
- [mafintosh/discovery-swarm][swarm]
- [mafintosh/ddatabase][core]
- [mafintosh/dwebfs][drive]
- [mafintosh/dappdb][db]
- [mafintosh/dweb-discovery-swarm][swarm]

## License
ISC

[core]: https://github.com/mafintosh/hypercore
[drive]: https://github.com/mafintosh/hyperdrive
[db]: https://github.com/mafintosh/hyperdb
[swarm]: https://github.com/mafintosh/discovery-swarm
[core]: https://github.com/distributedweb/ddatabase
[drive]: https://github.com/distributedweb/dwebfs
[db]: https://github.com/distributedweb/dappdb
[swarm]: https://github.com/distributedweb/dweb-discovery-swarm
14 changes: 7 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var tape = require('tape')
var hypercore = require('hypercore')
var hyperdb = require('hyperdb')
var ddatabase = require('ddatabase')
var dappdb = require('dappdb')
var ram = require('random-access-memory')
var swarm = require('.')

function getHypercoreSwarms (opts, cb) {
var feed1 = hypercore(ram)
var feed1 = ddatabase(ram)
feed1.once('ready', function () {
var feed2 = hypercore(ram, feed1.key)
var feed2 = ddatabase(ram, feed1.key)
feed2.once('ready', function () {
var write = swarm(feed1, opts)
var read = swarm(feed2, opts)
Expand All @@ -18,9 +18,9 @@ function getHypercoreSwarms (opts, cb) {
}

function getDbSwarms (opts, cb) {
var db1 = hyperdb(ram, {valueEncoding: 'utf-8'})
var db1 = dappdb(ram, {valueEncoding: 'utf-8'})
db1.once('ready', function () {
var db2 = hyperdb(ram, db1.key, {valueEncoding: 'utf-8'})
var db2 = dappdb(ram, db1.key, {valueEncoding: 'utf-8'})
db2.once('ready', function () {
var write = swarm(db1, opts)
var read = swarm(db2, opts)
Expand Down Expand Up @@ -92,7 +92,7 @@ tape('connect without utp', function (t) {
})
})

tape('hyperdb connect and close', function (t) {
tape('dappdb connect and close', function (t) {
t.plan(6)
getDbSwarms({}, function (swarms) {
var write = swarms[0]
Expand Down

0 comments on commit 7a6939a

Please sign in to comment.