-
Notifications
You must be signed in to change notification settings - Fork 11
Description
(thanks to @guillemcordoba for these explanations)
How it should be
In holochain, all activities should be idempotent: the order of global events should not affect the final state of the entries. There’s a couple of exceptions to that, but we can leave them for later.
This means that, for example, when we create entry A, remove entry A, and create entry A, the entry remains removed, since the remove_entry command has priority over the create ones.
What we have now
In LeaP we're updating the same entry multiple times with newer contents. But if you think about it, this can’t work, since two updates to the same entry are not idempotent (it matters A LOT in the global order of events, in this case which update came first). So this is not a behavior holochain should allow.
This means that any entry can only be updated once. If we want to do another update, we need to update the second address. For example, if entry A is updated to entry B, I can no longer update to C using A’s address, but I have to update to C using B’s address.
Solution
We split the course entry into two:
1. Anchor course entry: does not change, only contains information needed to make this course unique.
2. Changing info entry: with the list of modules and the title, this is the entry that gets updated every time.
And every time we create or update a course, we don’t update the anchor, but only the changing info entry. And then we add a link from the unchanging anchor to the latest version of the changing one. This way, we can always query the anchor entry with get_links and the first one, which will we the last one added, will point to the latest version of the changing entry.