-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Awesome Endeavour: DHT Part II #856
Changes from all commits
53a3f32
28f5641
8ecb7b5
f9cd739
eadd7d5
4453b55
2a76f98
045e305
2956637
2651787
02d1704
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,6 @@ You can check the development status at the [Kanban Board](https://waffle.io/ipf | |
|
||
[![Throughput Graph](https://graphs.waffle.io/ipfs/js-ipfs/throughput.svg)](https://waffle.io/ipfs/js-ipfs/metrics/throughput) | ||
|
||
**Please read this:** DHT (automatic content discovery) and Circuit Relay (pierce through NATs and dial between any node in the network) are two fundamental pieces that are not finalized yet. There are multiple applications that can be built without these two services but nevertheless they are fundamental to get that magic IPFS experience. If you want to track progress or contribute, please follow: | ||
|
||
- DHT: https://github.com/ipfs/js-ipfs/pull/856 | ||
- ✅ Relay: https://github.com/ipfs/js-ipfs/pull/1063 | ||
|
||
[**`Weekly Core Dev Calls`**](https://github.com/ipfs/pm/issues/650) | ||
|
||
## Tech Lead | ||
|
@@ -319,7 +314,6 @@ Enable and configure experimental features. | |
- `pubsub` (boolean): Enable libp2p pub-sub. (Default: `false`) | ||
- `ipnsPubsub` (boolean): Enable pub-sub on IPNS. (Default: `false`) | ||
- `sharding` (boolean): Enable directory sharding. Directories that have many child objects will be represented by multiple DAG nodes instead of just one. It can improve lookup performance when a directory has several thousand files or more. (Default: `false`) | ||
- `dht` (boolean): Enable KadDHT. **This is currently not interoperable with `go-ipfs`.** | ||
vasco-santos marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will the DHT start automatically in the browser too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the current state of this PR it is starting automatically in both browser and node. Do you think we should start by having only node.js nodes first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend to start with node only and look at adding it to the browser as a default later, if ever. Until we get more performance benchmarking for the browser I'm hesitant to just turn it on there for everyone. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, that's a good point! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so, I'm half inclined to just enable it in the browser by default, expose ourselves to the issues and get them fixed asap. That said, since this is such a big feature perhaps not having it enabled by default in the browser initially will give us some scope to test it out first and fix the bigger issues, so that we don't expose all our users to the bugs and make everyone mad. We do need a way to enable/disable it though - if the |
||
|
||
##### `options.config` | ||
|
||
|
@@ -600,7 +594,13 @@ The core API is grouped into several areas: | |
- [`ipfs.bootstrap.add(addr, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstrapadd) | ||
- [`ipfs.bootstrap.rm(peer, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstraprm) | ||
|
||
- dht (not implemented yet) | ||
- [dht](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/) | ||
- [`ipfs.dht.findPeer(peerId, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtfindpeer) | ||
- [`ipfs.dht.findProvs(multihash, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtfindprovs) | ||
- [`ipfs.dht.get(key, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtget) | ||
- [`ipfs.dht.provide(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtprovide) | ||
- [`ipfs.dht.put(key, value, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtput) | ||
- [`ipfs.dht.query(peerId, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtquery) | ||
|
||
- [pubsub](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md) | ||
- [`ipfs.pubsub.subscribe(topic, handler, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md#pubsubsubscribe) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
command: 'dht <command>', | ||
|
||
description: 'Issue commands directly through the DHT.', | ||
|
||
builder (yargs) { | ||
return yargs.commandDir('dht') | ||
}, | ||
|
||
handler (argv) { | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the DHT full implemented on http api and CLI as well? Mind updating https://github.com/ipfs/ipfs/blob/master/IMPLEMENTATION_STATUS.md#dht ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in ipfs/ipfs#388 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'findpeer <peerID>', | ||
|
||
describe: 'Find the multiaddresses associated with a Peer ID.', | ||
|
||
builder: {}, | ||
|
||
handler ({ getIpfs, peerID, resolve }) { | ||
resolve((async () => { | ||
const ipfs = await getIpfs() | ||
const peers = await ipfs.dht.findPeer(peerID) | ||
const addresses = peers.multiaddrs.toArray().map((ma) => ma.toString()) | ||
|
||
addresses.forEach((addr) => { | ||
print(addr) | ||
}) | ||
})()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'findprovs <key>', | ||
|
||
describe: 'Find peers that can provide a specific value, given a key.', | ||
|
||
builder: { | ||
'num-providers': { | ||
alias: 'n', | ||
describe: 'The number of providers to find. Default: 20.', | ||
default: 20 | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
const { getIpfs, key, resolve } = argv | ||
const opts = { | ||
maxNumProviders: argv['num-providers'] | ||
} | ||
|
||
resolve((async () => { | ||
const ipfs = await getIpfs() | ||
const provs = await ipfs.dht.findProvs(key, opts) | ||
|
||
provs.forEach((element) => { | ||
print(element.id.toB58String()) | ||
}) | ||
})()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'get <key>', | ||
|
||
describe: 'Given a key, query the routing system for its best value.', | ||
|
||
builder: {}, | ||
|
||
handler ({ getIpfs, key, resolve }) { | ||
resolve((async () => { | ||
const ipfs = await getIpfs() | ||
const value = await ipfs.dht.get(key) | ||
|
||
print(value) | ||
})()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
command: 'provide <key>', | ||
|
||
describe: 'Announce to the network that you are providing given values.', | ||
|
||
builder: { | ||
recursive: { | ||
alias: 'r', | ||
recursive: 'Recursively provide entire graph.', | ||
default: false | ||
} | ||
}, | ||
|
||
handler ({ getIpfs, key, recursive, resolve }) { | ||
const opts = { | ||
recursive | ||
} | ||
|
||
resolve((async () => { | ||
const ipfs = await getIpfs() | ||
await ipfs.dht.provide(key, opts) | ||
})()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
command: 'put <key> <value>', | ||
|
||
describe: 'Write a key/value pair to the routing system.', | ||
|
||
builder: {}, | ||
|
||
handler ({ getIpfs, key, value, resolve }) { | ||
resolve((async () => { | ||
const ipfs = await getIpfs() | ||
await ipfs.dht.put(key, value) | ||
})()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'query <peerID>', | ||
|
||
describe: 'Find the closest Peer IDs to a given Peer ID by querying the DHT.', | ||
|
||
builder: {}, | ||
|
||
handler ({ getIpfs, peerID, resolve }) { | ||
resolve((async () => { | ||
const ipfs = await getIpfs() | ||
const result = await ipfs.dht.query(peerID) | ||
|
||
result.forEach((peerID) => { | ||
print(peerID.id.toB58String()) | ||
}) | ||
})()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.