I'm about to implement replaceable events in nostrdb and just had an idea that fix the contact-list unfollow problem for good: when replacing a note with a new note, generate a "delta", which is the difference between the old and new note (tags, contents, etc). This delta can be quite small, so it can be done automatically for all replaceable events. This would enable any nostrdb app (damus ios, notedeck, etc) to "self-heal". it could detect simulatenous follow and unfollows and discard the unfollows. You could also use this to show diffs in longform posts, and follow/unfollow histories for all users in your local db.

Replies (9)

there can be situations where another client is updating an older version of one you have locally that is newer. this would technically be the "newest" even though its updating an older list. A delta would notice something is off
chatgpt things so: CRDT-Based Approach Model the contact list as a Set CRDT: • Add-Wins Set (AWSet): Always prefer additions to the set unless explicitly removed. • Ensure removals are deliberate by tracking deletion markers (tombstones) for each p tag. hrm
Now that i think about it, the safest thing to do is ask the user which follows and unfollows were intentional whenever it notices that it is updating multiple p tags at once. You don’t even need historical deltas for this
Will might want to checkout NIP-62, with the new a/A tag structure and the auto-update field. That said, we're also probably going to handle versioning over a relay or database. That's a storage-service question, but the new event type makes it easy to at least check one event-version back and notice if the e/E tags have changed.