Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into refactor/use-exporter-w-cid-instances
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Mar 18, 2019
2 parents 8d8a2fb + e38b81d commit 16d1670
Show file tree
Hide file tree
Showing 66 changed files with 562 additions and 255 deletions.
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
<a name="0.35.0-rc.0"></a>
# [0.35.0-rc.0](https://github.com/ipfs/js-ipfs/compare/v0.35.0-pre.0...v0.35.0-rc.0) (2019-03-06)


### Bug Fixes

* add support for resolving to the middle of an IPLD block ([#1841](https://github.com/ipfs/js-ipfs/issues/1841)) ([fc08243](https://github.com/ipfs/js-ipfs/commit/fc08243))
* dht browser disabled ([#1879](https://github.com/ipfs/js-ipfs/issues/1879)) ([7c5a843](https://github.com/ipfs/js-ipfs/commit/7c5a843))
* ipv6 multiaddr in stdout ([#1854](https://github.com/ipfs/js-ipfs/issues/1854)) ([35fd541](https://github.com/ipfs/js-ipfs/commit/35fd541)), closes [#1853](https://github.com/ipfs/js-ipfs/issues/1853)
* make clear pins function in tests serial ([#1910](https://github.com/ipfs/js-ipfs/issues/1910)) ([503e5ac](https://github.com/ipfs/js-ipfs/commit/503e5ac)), closes [#1890](https://github.com/ipfs/js-ipfs/issues/1890)
* pin.rm test EPERM rename ([#1889](https://github.com/ipfs/js-ipfs/issues/1889)) ([c60de74](https://github.com/ipfs/js-ipfs/commit/c60de74))
* temporarily disable random walk dht discovery ([#1907](https://github.com/ipfs/js-ipfs/issues/1907)) ([3fff46a](https://github.com/ipfs/js-ipfs/commit/3fff46a))


### Code Refactoring

* export types and utilities statically ([#1908](https://github.com/ipfs/js-ipfs/issues/1908)) ([79d7fef](https://github.com/ipfs/js-ipfs/commit/79d7fef))


### Features

* add `--enable-preload` to enable/disable preloading for daemons ([#1909](https://github.com/ipfs/js-ipfs/issues/1909)) ([9470900](https://github.com/ipfs/js-ipfs/commit/9470900))
* limit connections number ([#1872](https://github.com/ipfs/js-ipfs/issues/1872)) ([bebce7f](https://github.com/ipfs/js-ipfs/commit/bebce7f))


### BREAKING CHANGES

* `ipfs.util.isIPFS` and `ipfs.util.crypto` have moved to static exports and should be accessed via `const { isIPFS, crypto } = require('ipfs')`.

The modules available under `ipfs.types.*` have also become static exports.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
* `ipfs.resolve` now supports resolving to the middle of an IPLD block instead of erroring.

Given:

```js
b = {"c": "some value"}
a = {"b": {"/": cidOf(b) }}
```

`ipfs resolve /ipld/cidOf(a)/b/c` should return `/ipld/cidOf(b)/c`. That is, it resolves the path as much as it can.

Previously it would simply fail with an error.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>



<a name="0.35.0-pre.0"></a>
# [0.35.0-pre.0](https://github.com/ipfs/js-ipfs/compare/v0.34.4...v0.35.0-pre.0) (2019-02-11)

Expand Down
2 changes: 1 addition & 1 deletion ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ One of following:
This is for you! Please read, and then delete this text before posting it.
The js-ipfs issues are only for bug reports and directly actionable features.
Read https://github.com/ipfs/community/blob/master/contributing.md#reporting-issues if your issue doesn't fit either of those categories.
Read https://github.com/ipfs/community/blob/master/CONTRIBUTING.md#reporting-issues if your issue doesn't fit either of those categories.
-->
106 changes: 55 additions & 51 deletions README.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions examples/browser-add-readable-stream/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

const repoPath = `ipfs-${Math.random()}`
const ipfs = new Ipfs({ repo: repoPath })
const { Buffer } = Ipfs

ipfs.on('ready', () => {
const directory = 'directory'
Expand Down Expand Up @@ -41,13 +42,13 @@ const createFiles = (directory) => {
path: `${directory}/file1.txt`,

// content could be a stream, a url etc
content: ipfs.types.Buffer.from('one', 'utf8')
content: Buffer.from('one', 'utf8')
}, {
path: `${directory}/file2.txt`,
content: ipfs.types.Buffer.from('two', 'utf8')
content: Buffer.from('two', 'utf8')
}, {
path: `${directory}/file3.txt`,
content: ipfs.types.Buffer.from('three', 'utf8')
content: Buffer.from('three', 'utf8')
}]
}

Expand Down
4 changes: 2 additions & 2 deletions examples/browser-create-react-app/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "IPFS React App",
"name": "IPFS Create React App Example",
"icons": [
{
"src": "favicon.ico",
Expand Down
18 changes: 9 additions & 9 deletions examples/browser-create-react-app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import useIpfs from './hooks/use-ipfs.js'
import logo from './ipfs-logo.svg'

const App = () => {
const { ipfs, ipfsInitError } = useIpfsFactory({commands: ['id']})
const { ipfs, ipfsInitError } = useIpfsFactory({ commands: ['id'] })
const id = useIpfs(ipfs, 'id')
return (
<div className='sans-serif'>
<header className="flex items-center pa3 bg-navy bb bw3 b--aqua">
<a href="https://ipfs.io" title="home">
<img alt="IPFS logo" src={logo} style={{ height: 50 }} className='v-top' />
<header className='flex items-center pa3 bg-navy bb bw3 b--aqua'>
<a href='https://ipfs.io' title='home'>
<img alt='IPFS logo' src={logo} style={{ height: 50 }} className='v-top' />
</a>
<h1 className="flex-auto ma0 tr f3 fw2 montserrat aqua">IPFS React</h1>
<h1 className='flex-auto ma0 tr f3 fw2 montserrat aqua'>IPFS React</h1>
</header>
<main>
{ipfsInitError && (
Expand All @@ -26,20 +26,20 @@ const App = () => {
)
}

const Title = ({children}) => {
const Title = ({ children }) => {
return (
<h2 className="f5 ma0 pb2 tracked aqua fw4 montserrat">{children}</h2>
<h2 className='f5 ma0 pb2 tracked aqua fw4 montserrat'>{children}</h2>
)
}

const IpfsId = (props) => {
if (!props) return null
if (!props) return null
return (
<section className='bg-snow mw7 center mt5'>
<h1 className='f3 fw4 ma0 pv3 aqua montserrat tc'>Connected to IPFS</h1>
<div className='pa4'>
{['id', 'agentVersion'].map((key) => (
<div className="mb4" key={key}>
<div className='mb4' key={key}>
<Title>{key}</Title>
<div className='bg-white pa2 br2 truncate monospace'>{props[key]}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-create-react-app/src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
ReactDOM.unmountComponentAtNode(div)
});
})
12 changes: 5 additions & 7 deletions examples/browser-create-react-app/src/hooks/use-ipfs-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ let ipfs = null
* so use-ipfs calls can grab it from there rather than expecting
* it to be passed in.
*/
export default function useIpfsFactory ({commands}) {
const [isIpfsReady, setIpfsReady] = useState(!!ipfs)
export default function useIpfsFactory ({ commands }) {
const [isIpfsReady, setIpfsReady] = useState(Boolean(ipfs))
const [ipfsInitError, setIpfsInitError] = useState(null)

useEffect(() => {
Expand All @@ -34,11 +34,9 @@ export default function useIpfsFactory ({commands}) {
async function startIpfs () {
if (ipfs) {
console.log('IPFS already started')

} else if (window.ipfs && window.ipfs.enable) {
console.log('Found window.ipfs')
ipfs = await window.ipfs.enable({commands})

ipfs = await window.ipfs.enable({ commands })
} else {
try {
console.time('IPFS Started')
Expand All @@ -51,10 +49,10 @@ export default function useIpfsFactory ({commands}) {
}
}

setIpfsReady(!!ipfs)
setIpfsReady(Boolean(ipfs))
}

return {ipfs, isIpfsReady, ipfsInitError}
return { ipfs, isIpfsReady, ipfsInitError }
}

function promiseMeJsIpfs (Ipfs, opts) {
Expand Down
4 changes: 3 additions & 1 deletion examples/browser-readablestream/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const { Buffer } = require('../../')

const log = (line) => {
const output = document.getElementById('output')
let message
Expand Down Expand Up @@ -40,7 +42,7 @@ const dragDrop = (ipfs) => {
reader.onload = (event) => {
ipfs.add({
path: file.name,
content: ipfs.types.Buffer.from(event.target.result)
content: Buffer.from(event.target.result)
}, {
progress: (addedBytes) => {
progress.textContent = `IPFS: Adding ${file.name} ${parseInt((addedBytes / file.size) * 100)}%\r\n`
Expand Down
66 changes: 66 additions & 0 deletions examples/running-multiple-nodes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Running multiple JS IPFS nodes

This example takes you through the process needed to run 2 or more JS IPFS nodes on the same computer.

## Via the CLI

Firstly, you'll want to use the `IPFS_PATH` env variable to get a different repo for each instance. Initialise a new IPFS repo like this:

```sh
# IPFS_PATH by default is `~/.jsipfs`.
# The following instructs JS IPFS to use the path `~/.jsipfs2` instead:
IPFS_PATH=~/.jsipfs2 jsipfs init

# Repeat this for as many nodes as you want to run...
```

Secondly, you'll need them to bind to different ports because otherwise bad things happen.

With the CLI, after you've run `ipfs init` you can either edit the config file at `~/.jsipfs/config` (replacing `~/.jsipfs` with the repo path you specified above) or use the config command to update the config e.g. `ipfs config Addresses.API /ip4/0.0.0.0/tcp/4012`. Then start the node with `ipfs daemon`:

```sh
# edit the address ports
vi ~/.jsipfs2/config

# OR

IPFS_PATH=~/.jsipfs2 jsipfs config Addresses.API /ip4/127.0.0.1/tcp/5012

# Repeat this for as many nodes as you want to run...
```

```sh
# ...and then start the daemon
IPFS_PATH=~/.jsipfs2 jsipfs daemon

# Repeat this for as many nodes as you want to run...
```

## Programmatically

Firstly, you'll want to pass the [`repo`](https://github.com/ipfs/js-ipfs#optionsrepo) option to the constructor to get a different repo for each instance:

```js
// The repo path by default is `os.homedir() + '/.jsipfs'`.
new IPFS({ repo: os.homedir() + '/.jsipfs2' })
```

Secondly, you'll need them to bind to different ports because otherwise bad things happen.

To do this, simply pass the different ports to the [`config`](https://github.com/ipfs/js-ipfs#optionsconfig) constructor option. All together:

```js
new IPFS({
repo: os.homedir() + '/.jsipfs2',
config: {
Addresses: {
Swarm: [
'/ip4/0.0.0.0/tcp/4012',
'/ip4/127.0.0.1/tcp/4013/ws'
],
API: '/ip4/127.0.0.1/tcp/5012',
Gateway: '/ip4/127.0.0.1/tcp/9191'
}
}
})
```
6 changes: 3 additions & 3 deletions package-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Package",
"Version",
"Deps",
"CI",
"CI/Travis",
"Coverage",
"Lead Maintainer"
],
Expand All @@ -30,7 +30,7 @@
["libp2p/js-libp2p-kad-dht", "libp2p-kad-dht"],
["libp2p/js-libp2p-mdns", "libp2p-mdns"],
["libp2p/js-libp2p-mplex", "libp2p-mplex"],
["libp2p/js-libp2p-railing", "libp2p-railing"],
["libp2p/js-libp2p-bootstrap", "libp2p-bootstrap"],
["libp2p/js-libp2p-secio", "libp2p-secio"],
["libp2p/js-libp2p-tcp", "libp2p-tcp"],
["libp2p/js-libp2p-webrtc-star", "libp2p-webrtc-star"],
Expand All @@ -51,7 +51,7 @@

"Generics/Utils",
["ipfs/js-ipfs-http-client", "ipfs-http-client"],
["ipfs/ipfs-multipart", "ipfs-multipart"],
["ipfs/js-ipfs-multipart", "ipfs-multipart"],
["ipfs/is-ipfs", "is-ipfs"],
["multiformats/js-multihashing", "multihashing"],
["multiformats/js-mafmt", "mafmt"]
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ipfs",
"version": "0.35.0-pre.0",
"version": "0.35.0-rc.0",
"description": "JavaScript implementation of the IPFS specification",
"leadMaintainer": "Alan Shaw <alan@tableflip.io>",
"bin": {
Expand Down Expand Up @@ -127,10 +127,10 @@
"joi": "^14.3.0",
"joi-browser": "^13.4.0",
"joi-multiaddr": "^4.0.0",
"libp2p": "~0.25.0-rc.0",
"libp2p": "~0.25.0-rc.3",
"libp2p-bootstrap": "~0.9.3",
"libp2p-crypto": "~0.16.0",
"libp2p-kad-dht": "~0.14.4",
"libp2p-kad-dht": "~0.14.7",
"libp2p-keychain": "~0.3.3",
"libp2p-mdns": "~0.12.0",
"libp2p-mplex": "~0.8.4",
Expand All @@ -147,6 +147,7 @@
"multiaddr": "^6.0.0",
"multiaddr-to-uri": "^4.0.1",
"multibase": "~0.6.0",
"multicodec": "~0.5.0",
"multihashes": "~0.4.14",
"multihashing-async": "~0.5.1",
"node-fetch": "^2.3.0",
Expand Down Expand Up @@ -189,6 +190,7 @@
"Alan Shaw <alan@tableflip.io>",
"Alex North <alex@alexnorth.me>",
"Alex Potsides <alex@achingbrain.net>",
"Andrew Nesbitt <andrewnez@gmail.com>",
"Andrew de Andrade <andrew@deandrade.com.br>",
"André Cruz <andremiguelcruz@msn.com>",
"Arkadiy Kukarkin <parkan@users.noreply.github.com>",
Expand Down Expand Up @@ -248,6 +250,7 @@
"Mikeal Rogers <mikeal.rogers@gmail.com>",
"Mithgol <getgit@mithgol.ru>",
"Molly <momack2@users.noreply.github.com>",
"Mounish Sai <pvsmounish@gmail.com>",
"My9Bot <34904312+My9Bot@users.noreply.github.com>",
"Nuno Nogueira <nunofmn@gmail.com>",
"Oli Evans <oli@tableflip.io>",
Expand Down Expand Up @@ -293,4 +296,4 @@
"Łukasz Magiera <magik6k@users.noreply.github.com>",
"Максим Ильин <negamaxi@gmail.com>"
]
}
}
9 changes: 9 additions & 0 deletions src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const os = require('os')
const { getRepoPath, print, ipfsPathHelp } = require('../utils')

module.exports = {
Expand All @@ -26,11 +27,18 @@ module.exports = {
type: 'boolean',
default: false
})
.option('enable-preload', {
type: 'boolean',
default: true
})
},

handler (argv) {
argv.resolve((async () => {
print('Initializing IPFS daemon...')
print(`js-ipfs version: ${require('../../../package.json').version}`)
print(`System version: ${os.arch()}/${os.platform()}`)
print(`Node.js version: ${process.versions.node}`)

const repoPath = getRepoPath()

Expand All @@ -41,6 +49,7 @@ module.exports = {
repo: process.env.IPFS_PATH,
offline: argv.offline,
pass: argv.pass,
preload: { enabled: argv.enablePreload },
EXPERIMENTAL: {
pubsub: argv.enablePubsubExperiment,
ipnsPubsub: argv.enableNamesysPubsub,
Expand Down
4 changes: 2 additions & 2 deletions src/core/components/dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const nextTick = require('async/nextTick')
const errcode = require('err-code')

const debug = require('debug')
const log = debug('jsipfs:dht')
log.error = debug('jsipfs:dht:error')
const log = debug('ipfs:dht')
log.error = debug('ipfs:dht:error')

module.exports = (self) => {
return {
Expand Down
Loading

0 comments on commit 16d1670

Please sign in to comment.