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

fix(core): return promise from 'dag.resolve' #3131

Closed
wants to merge 1 commit into from

Conversation

tarunbatra
Copy link
Contributor

@tarunbatra tarunbatra commented Jun 29, 2020

For #2962

@tarunbatra
Copy link
Contributor Author

@achingbrain I'm working on adding tests and documentation. Wanted to validate my approach with you.

Apart from adding tests in interface-ipfs-core/src/dag/resolve.js, would we also want to have tests in ipfs/test/core/dag.spec.js. What is the difference there?

}

} finally {
if (release) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is release defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release was supposed to be initiated by release = gcLock.readLock() which i picked up from ./put.js. But now I dont think it makes sense here. So removed this block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in ipfs.dag.put because adding blocks and pinning are async operations so gc could run between them which would result in the blocks being removed immediately after they were added.

We're only reading here, not writing so the lock is unnecessary.

@achingbrain
Copy link
Member

Apart from adding tests in interface-ipfs-core/src/dag/resolve.js, would we also want to have tests in ipfs/test/core/dag.spec.js. What is the difference there?

The tests in interface-ipfs-core are the core API tests - that is, everything in /docs/core-api should have tests in that package. They are run against ipfs core, against the http API via ipfs-http-client and against go-ipfs also via ipfs-http-client.

The tests in /packages/ipfs/test cover functionality not in the core-api.

Since the idea here is to document this method in the core api, tests should be in the interface-ipfs-core pacakge.

achingbrain added a commit that referenced this pull request Jul 9, 2020
Makes `ipfs.dag.resolve` behave the same when calling into core and over the http api.

Adds documentation and interface tests for `ipfs.dag.resolve`.

Supersedes #3131
Fixes #2962

BREAKING CHANGES:

- `ipfs.dag.resolve` returns `Promise<{ cid, remainderPath }` instead of `AsyncIterator<{ value, remainderPath }>`
  - Previously the core api returned an async iterator and the http client returned a simple promise

Co-authored-by: Tarun Batra <[email protected]>
@achingbrain
Copy link
Member

Fixed by #3152 - I added you as a co-author so you'll appear in the contributors list. Thanks!

@achingbrain achingbrain closed this Jul 9, 2020
@tarunbatra
Copy link
Contributor Author

Thanks @achingbrain. I planned to write tests and documentation but couldn't find time. #3152 looks great. Appreciate your help!

@achingbrain
Copy link
Member

No worries, sometimes the real world gets in the way - thanks for kicking it off.

SgtPooki referenced this pull request in ipfs/js-kubo-rpc-client Aug 18, 2022
Makes `ipfs.dag.resolve` behave the same when calling into core and over the http api.

Adds documentation and interface tests for `ipfs.dag.resolve`.

Supersedes #3131
Fixes #2962

BREAKING CHANGES:

- `ipfs.dag.resolve` returns `Promise<{ cid, remainderPath }` instead of `AsyncIterator<{ value, remainderPath }>`
  - Previously the core api returned an async iterator and the http client returned a simple promise

Co-authored-by: Tarun Batra <[email protected]>
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.

2 participants