peer-base / peer-pad

📝 Online editor providing collaborative editing in really real-time using CRDTs and IPFS.
https://peerpad.net
MIT License
678 stars 57 forks source link

WIP: IPLD/IPNS backups for pinner #297

Open jimpick opened 5 years ago

jimpick commented 5 years ago

The existing peer-base pinner will persist data to ~/.jsipfs, which works great.

But we'd like to deploy the pinner to Heroku, which has an ephemeral disk. On redeploys, the virtual machine will have a fresh disk, which will lose the pinned data.

As an extra layer, I'm going to try to write the pinner state out to IPLD on each state change, and call the ipfs-cluster API to pin it permanently. Additionally, we can use IPNS to keep track of the current head.

As a proof-of-concept, I've figured out how to save and retrieve the pinner state out-of-band from the IPFS datastore using the filesystem here:

https://github.com/jimpick/peer-pad/blob/jim-dev/pinner/index.js#L117

Next, I'm going to try to use IPLD and IPNS instead of fs to store the out-of-band backups.

jimpick commented 5 years ago

Making some progress:

https://github.com/ipfs-shipyard/peer-base-pinner

I had to tweak IPNS (go-ipfs), but it can now save and retrieve pinned state across heroku reboots (the IPFS repo needs to be recreated after each reboot because of the ephemeral disks). I'll be added in some support to pin to ipfs-cluster, and with that, we should have a solution for durable pinning that will enable us to deploy the dev PeerPad to production.

It all needs lots of testing ... I think we'll be able to learn a lot from this pinning solution once we have it running in production.