Keeping the mudlist in sync
The mudlist is a shared datastore with a deterministic approach to conflicting data.
Each entry in the mudlist is 'owned by the router on which the corresponding mud was last connected. When a mud connects to a different router, this router takes over ownership of the corresponding record in the mudlist.
After connecting to a remote router for the first time, the local router should send an irn-mudlist-req packet using 0 for mudlistid.
The remote router should respond with an irn-mudlist-altered packet containing a new mudlist. If the mudlist is too large for a single packet, the part which does not fit should be sent as delta packets.
After connecting to a remote router, send an irn-mudlist-req containing the mudlist id last received from that router.
The remote router should respond by sending all changes since that mudlist id as delta packets. If it cannot reconstruct the history (ie: the mudlist id is too old), it will respond with an altered packet, and behave as if it received a 0 mudlist id
Upon receiving an irn-mudlist-delta concerning a specific mud, a router should implement the following checks:
- Is this about an existing mud or a new one. If new, accept the record and add it.
- Is the update claiming the mud to be online on another router? if so, the router should modify its local mudlist to assign ownership of the record to the router on which the mud came online. If there exists a local connection with the mud, the router should disconnect it.
- Is the update claiming the mud went offline on another router? If the mud is locally connected, respond with an irn-mudlist-delta claiming it is online at the local router. If it is not locally connected, verify if the router from which the update was received owns the mudlist entry. If so, modify it, if not, ignore the delta.
Upon receiving an irn-mudlist-altered packet a router should:
- Delete any muds from its local mudlist for which the sending router is responsible.
- Add all the muds in the packet if they are either not yet listed, or are currently connected to the source of the altered packet.