FatihBAKIR / blockstore

2 stars 1 forks source link

Garbage collection/blockchain compression #10

Open kylecrsn opened 6 years ago

kylecrsn commented 6 years ago

Since we care about the payload of old blocks (and thus can't rely on merckle trees to reduce chain size), we need to implement some form of garbage collection. One approach to this would be:

There's definitely some subtleties to consider here like the long-term uniqueness of the keys used (the approach above assumes keys will always be unique). This approach also has the implication that, while before we could see that a data entry was created, maybe updated, then deleted even though it isn't reflected from just the KV store at present time, after this we will no longer know that that data ever existed and it will be truly unrecoverable.

One nice thing is that while this node goes into GC mode to do all this, the other nodes can continue doing work uninterrupted, then once they get the <new_chain, checkpoint> packet, simply cut off the old chain before the checkpoint, point the prevHash of the checkpoint block at the end of the new chain, and continue about things. The GC node then just needs to hear from someone about the work that was done while it was GC'ing and catch up.