Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

refactor: async iterables #1174

Closed
wants to merge 41 commits into from
Closed

refactor: async iterables #1174

wants to merge 41 commits into from

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented Nov 21, 2019

TLDR;

  • Remove Node.js streams and pull streams
  • Remove callbacks
  • Remove peer-info and peer-id

Now that internals are all async/await/iterables and fetch the next step is to bubble up that goodness to the core API, removing the multiple stream APIs and removing callback support.

I'm also proposing removing peer-info and peer-id, since these drastically increase the bundle size by pulling in libp2p-crypto, for which 99% of it's capability is unused. In place of peer-id we return a CID, which can easily be converted to a PeerId instance via:

const peerId = PeerId.createFromCID(peerCid)

In place of peer-info we return an object { id: CID, addrs: Multiaddr[] }, which can easily be converted to a PeerInfo like:

const peerInfo = new PeerInfo(PeerId.createFromCID(info.id))
info.addrs.forEach(addr => peerInfo.multiaddrs.add(addr))

refs ipfs/js-ipfs#1670

TODO:

  • Refactor local tests
  • Refactor interface-ipfs-core tests
  • Document new APIs in interface-ipfs-core
  • Update README with API changes
  • Document upgrade path from Node.js/pull streams to async iterables

Alan Shaw added 30 commits November 19, 2019 13:09
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
BREAKING CHANGE: The `log.tail` method now returns an async iterator that yields log messages. Use it like:

```js
for await (const message of ipfs.log.tail()) {
  console.log(message)
}
```

Secondly, the response to a call to `log.level` now returns an object that has camel cased keys. i.e. `Message` and `Error` properties have changed to `message` and `error`.

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

* [ ] ipfs-inactive/interface-js-ipfs-core#561

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
BREAKING CHANGE: Dropped support for go-ipfs <= 0.4.4 in swarm.peers response

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
BREAKING CHANGE: The signature for `ipfs.mount` has changed from `ipfs.mount([ipfsPath], [ipnsPath])` to `ipfs.mount([options])`. Where `options` is an optional object that may contain two boolean properties `ipfsPath` and `ipnsPath`. The response object has also changed to be camel case. See https://docs.ipfs.io/reference/api/http/#api-v0-mount.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
BREAKING CHANGE: Default ping `count` of 1 in client has been removed. The default ping count is now whatever the IPFS node defaults it to (currently 10). If you specifically need 1 ping message then please pass `count: 1` in options for `ipfs.ping()`.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
Other endpoints are not supported by go-ipfs or js-ipfs and so have been removed.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
Alan Shaw added 10 commits November 21, 2019 11:52
resolves #1103

BREAKING CHANGE: Multi parameter constructor options are no longer supported. To create a new IPFS HTTP client, pass a single parameter to the constructor. The parameter can be one of:

* String, formatted as one of:
    * Multiaddr e.g. /ip4/127.0.0.1/tcp/5001
    * URL e.g. http://127.0.0.1:5001
* [Multiaddr](https://www.npmjs.com/package/multiaddr) instance
* Object, in format of either:
    * Address and path e.g. `{ apiAddr: '/ip4/127.0.0.1/tcp/5001': apiPath: '/api/v0' }` (Note: `apiAddr` can also be a string in URL form or a Multiaddr instance)
    * Node.js style address e.g. `{ host: '127.0.0.1', port: 5001, protocol: 'http' }`

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
@alanshaw
Copy link
Contributor Author

History cleaned up in #1183

@alanshaw alanshaw closed this Nov 27, 2019
@alanshaw alanshaw deleted the refactor/async-iterables branch November 27, 2019 10:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant