Skip to content

Commit

Permalink
Allow re-enrolling validators if they're enrolled
Browse files Browse the repository at this point in the history
This is a workaround for bosagora#824
  • Loading branch information
AndrejMitrovic committed May 21, 2020
1 parent 085430f commit 494aba2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/agora/consensus/EnrollmentManager.d
Expand Up @@ -351,6 +351,16 @@ public class EnrollmentManager
{
this.enroll_pool.remove(enroll.utxo_key);

// special-case: if the validator will expire in the next block
// then allow it to re-enroll in the current block. This way the
// validator can start validating a new cycle right away
// todo: it should be possible to schedule it more in advance
// and not exactly at cycle_end - 1!
const old_height = getEnrolledHeight(enroll.utxo_key);
if (old_height != size_t.max &&
block_height + 1 >= old_height + Enrollment.ValidatorCycle)
this.validator_set.remove(enroll.utxo_key);

if (!this.validator_set.add(block_height, finder, enroll))
return false;

Expand Down

0 comments on commit 494aba2

Please sign in to comment.