Discarding commits

The delivery service may reject a commit sent by a client. In this case, the application needs to ensure that the local state remains the same as it was before the commit was staged.

Cleaning up local state after discarded commits

Generally, if a commit is discarded (e.g. due to being rejected by the Delivery Service), it can be cleaned up by the application in the following way:

    // clear pending commit and reset state
    alice_group
        .clear_pending_commit(alice_provider.storage())
        .unwrap();

In general, the application only needs to complete the cleanup above in order to fully restore the local state to the way it was before the commit was staged.

In several other cases, additional cleanup may need to be done.

ExternalJoin

If a staged commit containing an external join proposal must be discarded, the entire MlsGroup instance should be discarded by the application.

    // delete the `MlsGroup`
    bob_group
        .delete(bob_provider.storage())
        .expect("Could not delete the group");

PreSharedKey

In addition to clearing the staged commit, the application may also clear the pre-shared key from storage.

    // clear the psk that was stored earlier, if necessary
    alice_provider
        .storage()
        .delete_psk(&psk)
        .expect("Could not delete stored psk");

    // clear pending commit and reset state
    alice_group
        .clear_pending_commit(alice_provider.storage())
        .expect("Could not clear pending commit");

Self Update

The storage provider may also be used by the application to store signature keypairs. For self updates that update a signature keypair for the client, if the application has stored a new keypair in the storage provider at this point, it can be deleted from the storage provider here.