hypertrie icon indicating copy to clipboard operation
hypertrie copied to clipboard

Add delete metadata so delete ops have a fixed seq

Open Frando opened this issue 5 years ago • 2 comments

If tracking a hypercore that is a hypertrie for changes, it's easy to track all put operations. However, deletes are not clearly identifieable from the log because they are (quoting mafintosh): "puts with a hash distance nearby key. You can’t trivially identity them with the differ".

For kappa-core style usecases things are much easier if each operation has a fixed sequence number by which it can be addressed and indexed. If deletes in Hypertrie were Nodes with the deleted key plus a deleted flag, that would be straightforward (which it is not at the moment).

Frando avatar Jul 01 '20 15:07 Frando

So the hypercore in hypertrie does not contain operations but just pointers to the current trie. That’s why deletes looks like puts cause it’s all just updated pointers.

To make it easier to identify I’m down to introduce a .deletes number that’s a seq to the entry this node deletes or 0 otherwise.

If anyone wants to volunteer a PR for that it’s appreciated otherwise we’ll get to it at some point

mafintosh avatar Jul 01 '20 16:07 mafintosh

I don't think adding that would be much harder than adding https://github.com/hypercore-protocol/hypertrie/blob/master/lib/put.js#L31 to the node when it's written + some tests

mafintosh avatar Jul 01 '20 19:07 mafintosh