Open avaer opened 4 years ago
If we relied on the packages being on IPFS, could we keep the hashes of the packages added to the world in memory and check whether they exist on the backend when we save?
Yes we could, that is what is being suggested here 👍 .
However, the IPFS hashing algorithm is pretty inefficient and intensive. So I might suggest doing SHA256 hashes instead for this check.
I think I was thinking if we need to do the IPFS hashing at all? I thought if we already have the packages existing locally in the world, then would we already have their hashes, to use for a presence check on the server?
This is all assuming we get rid of the import/export feature so any packages have to have come from IPFS anyway and so need to have an existing hash.
I thought if we already have the packages existing locally in the world, then would we already have their hashes
No, the use case is the user uploads the file to memory (the world). There is no hash at that point that we could use to query the server, and just the hashing is expensive.
This isn't exactly a solution, but I added dynamic package uploading (which gives it a hash on user demand) here: https://github.com/webaverse/xrpackage-site/pull/9
Right now world files saved by the frontend are XR Packages, but this might not be the right data model. Worlds are all about being modified and shared quickly, as opposed to a container for loadable baked content.
The main thing that keeps us from moving to JSON is the world import/export feature, but we could probably do away with that for now, if IPFS tracked packages are easy to share and modify.
A tangential issue is that world save actually re-uploads the entire set of packages to the server, which is slow. We could probably seriously optimize that by hashing the file on the frontend and checking if it is on the backend already. The problem is the IPFS hashing is generally slow (we do do it on the frontend). This could be optimized with perhaps moving to a local SHA-2 digest, though the server would need support for querying these.