This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR; Preload was sending preload requests for EVERY dag node of an added file. This is unnecessary as the preload request will recursively slurp down the entire graph. This PR fixes that behaviour.
Adding file(s) causes the preload module to preload any root nodes for the added content. It sends a HTTP request to preload for each root CID because the API on the preload nodes will fetch any children automatically. This greatly reduces the number of HTTP requests we have make when adding large files that are chunked into multiple nodes.
However, the issue was that the tests were checking that a CID had been requested for preload, not that it had been requested only once.
I was inspecting the debug output for preload because of the recent CORS issues we've been having and noticed that multiple preload requests for the same CID were being sent. Worse still, when adding large files, the child nodes were also being requested 😱
The issues are:
ipfs.add
causesobject.get
to be called for every file added. The issue with that is thatobject.get
will also attempt to preload the CID you pass it.ipfs.add
causespin.add
to be called for each root CID. This in turn causesdag.get
to be called for every node in the graph. The issue with that is thatdag.get
will also attempt to preload the CID you pass it.The solution in both cases is to tell
object.get
andpin.add
in the context ofipfs.add
to not preload the CIDs that they are passed.I've augmented the tests to ensure that only one of the required CIDs is requested from the preload nodes and with that change and the fixes to the code the tests are now passing.