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 (6)

Brilliant. Lists should have been event-driven (added/removed entry events) instead of updated through full state transfers. Saving the entire contact list as an event should be used only as an ocasional check-point rather than for every single change. In that way, you could always read the latest checkpoint and then apply the delta events in sequence one after the other to compute the current state.
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.