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:
-
Create a cancel message:
- Check the message type, if it doesn't have a
cancel_callback
, we raise an exception. - Get the message
M
which we want to cancel. IfM
doesn't exist, we raise an exception. - If
M
has been cancelled (or undone) before (whoseundo
is not 0), we raise an exception. - Create a cancel message for
M
. IfM
a message created by you, adispersy-cancel-own
message will be created. Otherwise, adispersy-cancel-other
will be created, but only if we have such a permission. If not, then we raise an exception.
- Check the message type, if it doesn't have a
-
Check an incoming cancel message:
- Make sure the message we want to cancel
M
exists. - 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.
- Make sure the message we want to cancel
-
On incoming cancel messages:
- Update the
undo
field in the database with the latest cancel messages. - Call
cancel_callback
. - ???? Do we want to remove the message from the database ????
- Update the
2. Scenarios
- A creates a message M1. A cancels M1: allowed.
- A creates a message M1. B cancels M1: NOT allowed.
- A creates a message M1. B has the cancel permission. B cancels M1: allowed.
- 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.