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

refactor: async await roundup #2683

Closed
wants to merge 43 commits into from
Closed

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Dec 17, 2019

A roundup of the following PRs:


To allow us to pass the interface tests, the timeout option is now supported in the object.get and refs APIs. It doesn't actually cancel the operation all the way down the stack, but allows the method call to return when the timeout is reached.

https://github.com/ipfs/js-ipfs/pull/2683/files#diff-47300e7ecd8989b6246221de88fc9a3cR170


Supersedes #2547


resolves #1438
resolves #1061
resolves #2257
resolves #2509
resolves #1670
refs ipfs-inactive/interface-js-ipfs-core#394

BREAKING CHANGE: IPFS.createNode removed

BREAKING CHANGE: IPFS is not a class that can be instantiated - use IPFS.create. An IPFS node instance is not an event emitter.

BREAKING CHANGE: Instance .ready property removed. Please use IPFS.create instead.

BREAKING CHANGE: Callbacks are no longer supported on any API methods. Please use a utility such as callbackify on API methods that return Promises to emulate previous behaviour.

BREAKING CHANGE: PeerId and PeerInfo classes are no longer statically exported from ipfs-http-client since they are no longer used internally.

BREAKING CHANGE: pin.add results now contain a cid property (a CID instance) instead of a string hash property.

BREAKING CHANGE: pin.ls now returns an async iterable.

BREAKING CHANGE: pin.ls results now contain a cid property (a CID instance) instead of a string hash property.

BREAKING CHANGE: pin.rm results now contain a cid property (a CID instance) instead of a string hash property.

BREAKING CHANGE: add now returns an async iterable.

BREAKING CHANGE: add results now contain a cid property (a CID instance) instead of a string hash property.

BREAKING CHANGE: addReadableStream, addPullStream have been removed.

BREAKING CHANGE: ls now returns an async iterable.

BREAKING CHANGE: ls results now contain a cid property (whose value is a CID instance) instead of a hash property.

BREAKING CHANGE: files.readPullStream and files.readReadableStream have been removed.

BREAKING CHANGE: files.read now returns an async iterable.

BREAKING CHANGE: files.lsPullStream and files.lsReadableStream have been removed.

BREAKING CHANGE: files.ls now returns an async iterable.

BREAKING CHANGE: files.ls results now contain a cid property (whose value is a CID instance) instead of a hash property.

BREAKING CHANGE: files.ls no longer takes a long option (in core) - you will receive all data by default.

BREAKING CHANGE: files.stat result now contains a cid property (whose value is a CID instance) instead of a hash property.

BREAKING CHANGE: get now returns an async iterable. The content property value for objects yielded from the iterator is now an async iterable that yields BufferList objects.

BREAKING CHANGE: stats.bw now returns an async iterable.

BREAKING CHANGE: addFromStream has been removed. Use add instead.

BREAKING CHANGE: addFromFs has been removed. Please use the exported globSource utility and pass the result to add. See the glob source documentation for more details and an example.

BREAKING CHANGE: addFromURL has been removed. Please use the exported urlSource utility and pass the result to add. See the URL source documentation for more details and an example.

BREAKING CHANGE: name.resolve now returns an async iterable. It yields increasingly more accurate resolved values as they are discovered until the best value is selected from the quorum of 16. The "best" resolved value is the last item yielded from the iterator. If you are interested only in this best value you could use it-last to extract it like so:

const last = require('it-last')
await last(ipfs.name.resolve('/ipns/QmHash'))

BREAKING CHANGE: block.rm now returns an async iterable.

BREAKING CHANGE: block.rm now yields objects of { cid: CID, error: Error }.

BREAKING CHANGE: dht.findProvs, dht.provide, dht.put and dht.query now all return an async iterable.

BREAKING CHANGE: dht.findPeer, dht.findProvs, dht.provide, dht.put and dht.query now yield/return an object { id: CID, addrs: Multiaddr[] } instead of a PeerInfo instance(s).

BREAKING CHANGE: refs and refs.local now return an async iterable.

BREAKING CHANGE: object.data now returns an async iterable that yields Buffer objects.

BREAKING CHANGE: ping now returns an async iterable.

BREAKING CHANGE: repo.gc now returns an async iterable.

BREAKING CHANGE: swarm.peers now returns an array of objects with a peer property that is a CID, instead of a PeerId instance.

BREAKING CHANGE: swarm.addrs now returns an array of objects { id: CID, addrs: Multiaddr[] } instead of PeerInfo instances.

BREAKING CHANGE: block.stat result now contains a cid property (whose value is a CID instance) instead of a key property.

BREAKING CHANGE: bitswap.wantlist now returns an array of CID instances.

BREAKING CHANGE: bitswap.stat result has changed - wantlist and peers values are now an array of CID instances.

BREAKING CHANGE: the init option passed to the IPFS constructor will now not take any initialization steps if it is set to false. Previously, the repo would be initialized if it already existed. This is no longer the case. If you wish to initialize a node but only if the repo exists, pass init: { allowNew: false } to the constructor.

BREAKING CHANGE: removed file ls command from the CLI and HTTP API.

BREAKING CHANGE: Delegated peer and content routing modules are no longer included as part of core (but are still available if starting a js-ipfs daemon from the command line). If you wish to use delegated routing and are creating your node programmatically in Node.js or the browser you must npm install libp2p-delegated-content-routing and/or npm install libp2p-delegated-peer-routing and provide configured instances of them in options.libp2p. See the module repos for further instructions:

@achingbrain
Copy link
Member

While you're making these changes it'd be great if you could git mv the files before editing them otherwise, since the diffs within individual files are so great, git is recording them as deletions & additions which makes following changes back through the history a lot harder.

@alanshaw
Copy link
Member Author

alanshaw commented Dec 17, 2019

I did some reading on this and as far as I can tell git mv is just shorthand for git add + git rm. There is auto-detection for renames in the diff engine but if you change a file enough it just considers it a different file. git doesn’t actually track renames.

https://git.wiki.kernel.org/index.php/GitFaq#Why_does_Git_not_.22track.22_renames.3F

@alanshaw alanshaw force-pushed the refactor/async-await-roundup branch 2 times, most recently from 3b81e07 to 2fe568f Compare December 17, 2019 22:29
@alanshaw alanshaw changed the base branch from feat/ipfsx-boot-and-add to master December 17, 2019 22:31
@alanshaw
Copy link
Member Author

@jacobheun all the core interface tests are passing (npm run test:node:interface) aside from the swarm tests. Any chance you can take a look?

@achingbrain
Copy link
Member

I did some reading on this and

Yes, this is true. My point is that we’re losing history for these files due to the scale of the edits even though a bunch of the logic remains the same (eg. the bit you’d actually want to look through the history for, to find out why a thing is the way it is).

It could be avoided if they renamed via git one way or another before the editing commenced.

@alanshaw
Copy link
Member Author

alanshaw commented Jan 6, 2020

I think we can do this @achingbrain if we don't squash the commits on merge - thanks for bringing it up 💯

@alanshaw alanshaw marked this pull request as ready for review January 17, 2020 13:26
@alanshaw
Copy link
Member Author

superseded by #2726

@alanshaw alanshaw closed this Jan 24, 2020
@alanshaw alanshaw deleted the refactor/async-await-roundup branch January 24, 2020 11:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants