Closed alanshaw closed 5 years ago
I quickly threw this together in response to https://github.com/ipfs/js-ipfs/issues/1788.
Right now, when attempting to get content not in the local repo, cid.buffer will be requested multiple times. See:
cid.buffer
https://github.com/ipfs/js-ipfs-repo/blob/01a47375f5a07c5b9b3312c1674923a3c2854ae8/src/blockstore.js#L163-L171
cidToDsKey accesses cid.buffer and will be called twice in this one method (and possibly other times throughout the code base) so in this case it is worth the overhead of caching the buffer because recreating it is expensive.
cidToDsKey
resolves https://github.com/ipfs/js-ipfs/issues/1788
@vmx shall we merge?
I quickly threw this together in response to https://github.com/ipfs/js-ipfs/issues/1788.
Right now, when attempting to get content not in the local repo,
cid.buffer
will be requested multiple times. See:https://github.com/ipfs/js-ipfs-repo/blob/01a47375f5a07c5b9b3312c1674923a3c2854ae8/src/blockstore.js#L163-L171
cidToDsKey
accessescid.buffer
and will be called twice in this one method (and possibly other times throughout the code base) so in this case it is worth the overhead of caching the buffer because recreating it is expensive.resolves https://github.com/ipfs/js-ipfs/issues/1788