-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Description
The leader election algorithm algorithm currently has a chance to fail, as explained in a comment at the top of the leaderelection.h file. There is a possible order of activations when there are only two candidates in the segment comparison phase, where both candidates will demote themselves.
The fix
This issue can be fixed as shown in this commit on my fork of AmoebotSim:
remcosurtel@b96d525
Firstly, in line 479 the hasCoveredCandidate variable on the FinalSegmentCleanToken should be set appropriately, and the isCoveredCandidate variable should be set to false afterwards.
Secondly, on line 354, when a candidate demotes itself because it is shorter than its predecessor, it should set its isCoveredCandidate variable to true to avoid its successor from also revoking its candidacy erroneously.
From my testing these two changes appear to completely eliminate the chance of failure.