[Design Discussion] Switch to keeping a single IPFS directory address in Gun?
Apparently IPFS is pretty smart about modified resources:
root@628dd289a8e6:/tmp# /node_modules/go-ipfs/bin/ipfs --api=/ip4/$( getent hosts ipfs | cut -d ' ' -f 1 )/tcp/5001 add -r ipfstest/
added QmNRxNyFAN3aW61qsyRUhZnKMPNAoHy91ktLtLfgEzJJm8 ipfstest/test1
added QmZNhZXeejz1nebssQVoLZptgYcyseaLPyTgNTvDo6YmYt ipfstest/test2
added Qmdb1FxJVBXK9rffNxMzPefczQeGByiui42eoEn4HzXUxc ipfstest/testdir1/test3
added QmXHm5fQ6jH6UbFGhrYpV4UYJSBisrkyt69oB61U9iXhnw ipfstest/testdir2/test4
added QmbasMx71y9VqF7Gu5cSR1LSUVjzVsZ6kv8Q84fk1wornH ipfstest/testdir2/test5
added QmQ21HkVtgHj6Q5fkM2JNsHxvUsyBc2QXoP4YsNXsFuKc3 ipfstest/testdir1
added QmazcfxeFukkyano7wtHUMzV5WiongVNfkj7oioD84uMbf ipfstest/testdir2
added QmR5aQS6eTUKm4YCCqtxgrtvGwopxHycHZZgCPoKNKmRcc ipfstest
145 B / 145 B [=====================================================] 100.00%
root@628dd289a8e6:/tmp# date > ipfstest/testdir2/test5
root@628dd289a8e6:/tmp# date > ipfstest/testdir2/test6
root@628dd289a8e6:/tmp# date > ipfstest/test2
root@628dd289a8e6:/tmp# /node_modules/go-ipfs/bin/ipfs --api=/ip4/$( getent hosts ipfs | cut -d ' ' -f 1 )/tcp/5001 add -r ipfstest/
added QmNRxNyFAN3aW61qsyRUhZnKMPNAoHy91ktLtLfgEzJJm8 ipfstest/test1
added QmQbrS4tGuaqJxzJ1ZQBjgJVYqSaaM74v1CvJ1mK87S5TV ipfstest/test2
added Qmdb1FxJVBXK9rffNxMzPefczQeGByiui42eoEn4HzXUxc ipfstest/testdir1/test3
added QmXHm5fQ6jH6UbFGhrYpV4UYJSBisrkyt69oB61U9iXhnw ipfstest/testdir2/test4
added QmUsijQuChQJqq1381XQp7va1aBAf1GebWSCLht756nAY4 ipfstest/testdir2/test5
added QmcYwvzgsy3ceJv4KAKRW4PXmUbuJEWTVsgu8upU4n88j4 ipfstest/testdir2/test6
added QmQ21HkVtgHj6Q5fkM2JNsHxvUsyBc2QXoP4YsNXsFuKc3 ipfstest/testdir1
added QmPftYxJeAwZgzKFffieHnfPXvn81ksYeoaSxTiNnccNXa ipfstest/testdir2
added QmY1SRpgHw83j5RQnyxYXUgDWVT1SrpYCQ5XVb1aLn5RVe ipfstest
174 B / 174 B [======================================================] 100.00%
Notice how the IPFS addresses of files that have not been modified do not change, but the address of the whole directory changes. So, a directory is not added as a single blob, but as a collection of independent files.
That means that we could reasonably only keep one IPFS address in Gun (the latest version of the whole directory) and rely on IPFS to fetch handle resolving each file. That would simplify things on the Gun side (no need for an entry for each file). Impact on reliability and speed is unclear.
It seems this is how IPNS works, in fact.
Edited by Michał "rysiek" Woźniak