Cancel Message - Tribler/dispersy GitHub Wiki

This page explains what the cancel message does.

1. How the cancel message works

The cancel message reuses the undo field in the sync table. The cancel message does exactly the same thing as the undo message except that a cancel message CANNOT cancel a cancel message.

Here is how it works:

  1. Create a cancel message:

    1. Check the message type, if it doesn't have a cancel_callback, we raise an exception.
    2. Get the message M which we want to cancel. If M doesn't exist, we raise an exception.
    3. If M has been cancelled (or undone) before (whose undo is not 0), we raise an exception.
    4. Create a cancel message for M. If M a message created by you, a dispersy-cancel-own message will be created. Otherwise, a dispersy-cancel-other will be created, but only if we have such a permission. If not, then we raise an exception.
  2. Check an incoming cancel message:

    1. Make sure the message we want to cancel M exists.
    2. Check if M is created by either the same peer, or if this peer has the permission to cancel others. If not drop the message.
  3. On incoming cancel messages:

    1. Update the undo field in the database with the latest cancel messages.
    2. Call cancel_callback.
    3. ???? Do we want to remove the message from the database ????

2. Scenarios

  1. A creates a message M1. A cancels M1: allowed.
  2. A creates a message M1. B cancels M1: NOT allowed.
  3. A creates a message M1. B has the cancel permission. B cancels M1: allowed.
  4. A creates a message M1. B has the cancel permission. B cancels M1. C revokes cancel permission of B: allowed, peers should reset the cancelled flag and maybe fetch the message in the future.