1

When we retrieve a file through IPFS, it caches the file in IPFS' repository. Later when we want to fetch the same file or its updated version, only block that contains the changed character will be fetched.

[Q] I was wondering does Swarm provide similar approach? or does it fetch complete file at each retrieve call?

1 Answer 1

4

In swarm "blocks" are called chunks.

If you download a chunk, it will be stored on your machine. Later, when requested, it will be retrieved locally.

Files are made up collections of chunks (organized in a Merkle Tree). If a version of a file contains one or more of the same chunks as the previous version, those chunks will still be retrieved locally.

A chunk will only be removed if you run out of storage space, and the storage layer detects that the chunk doesn't get used; the chunks accessed last time the longest time ago get removed first.

In fact, this is true for all nodes on the path of a retrieval; they will opportunistically store chunks in case they turn popular, in which case it's likely they'll be asked for the chunk again soon. This is because of the (upcoming) incentive layer, that pays nodes to serve chunks. Thus, popular chunks are valuable chunks, and will tend to be more generally available. This again means shorter path for a chunk request to travel.

It might also be of interest to note that swarm ultimately will provide an insurance scheme allowing you to pay the network up front for storing "unpopular" chunks. Then they won't get deleted, regardless of when they were last accessed.

2
  • What is the difference between chunks and blocks? @lash
    – alper
    Commented May 29, 2018 at 12:01
  • they are just semantics.
    – lash
    Commented May 31, 2018 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.