hypercore-protocol / hypercore-next

Hypercore 10 is an append only log with multi-writer primitives built in.
MIT License
150 stars 15 forks source link

Implement `core.clear()` #123

Closed kasperisager closed 1 year ago

kasperisager commented 1 year ago

@mafintosh Is core.clear() only a local thing or should it notify peers as well?

mafintosh commented 1 year ago

@kasperisager local-only, but other peers should be notified using a drop range message. then it can gossip later also if users want 👀

kasperisager commented 1 year ago

@mafintosh Is that as simple as:

this.replicator.onhave(start, end - start, true)
mafintosh commented 1 year ago

It is indeed!

mafintosh commented 1 year ago

@kasperisager and we'd wanna make sure this runs on the mutex also

kasperisager commented 1 year ago

@mafintosh I also need to make sure that this updates the contig pointer if necessary.

mafintosh commented 1 year ago

@kasperisager ya good catch on that

kasperisager commented 1 year ago

@mafintosh This is ready for another review.

kasperisager commented 1 year ago

@mafintosh Also, are there any observable behaviours during replication that I should test?

mafintosh commented 1 year ago

@kasperisager added a comment above, i think we can use the bitfield message in the oplog also to make this very safe (ie so it can be applied on restart, if fails half way through)

re replication. test the usual two peers and also a a->b->c scenario where b is the one that clears, so we know that the gossip works

mafintosh commented 1 year ago

@kasperisager good to go yea?

kasperisager commented 1 year ago

@mafintosh Should be, yes 👍