TryQuiet / quiet

A private, p2p alternative to Slack and Discord built on Tor & IPFS
https://www.tryquiet.org
GNU General Public License v3.0
1.98k stars 86 forks source link

Persist Sigchain changes on sync #2630

Open adrastaea opened 1 month ago

adrastaea commented 1 month ago

Description

In the first pass of persistence, #2626, we will just save the sigchain to a file when the application closes gracefully, but we want to be resilient against crashes and kills. To achieve this resiliency, we want to save the sigchain to persistent storage whenever a block is added. However, serializing the entire chain with Team.save() is very intensive because the hash of each link in chain is validated. Ideally, we would come up with some way to just append new blocks to the existing persistent store, or use OrbitDB as the storage for blocks in the chain so that blocks are automatically added to the persistent store when replicated. For this ticket, we will prioritize correctness over performance, and just add blocks to whatever persistent store we're using whenever the team state changes.

Acceptance Criteria

  1. New changes created or received on Sigchain should be persisted in LevelDB
  2. Persist on each change (prioritize correctness over performance, for now)