From ac0546baa03d427c4391e319a7de62a07c851694 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 20 Jul 2018 17:47:58 +1000 Subject: [PATCH] Tidy get_attesters_and_proposers --- src/state/transition/attestors.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/state/transition/attestors.rs b/src/state/transition/attestors.rs index 71bd56353b..e6a4783f4d 100644 --- a/src/state/transition/attestors.rs +++ b/src/state/transition/attestors.rs @@ -41,14 +41,29 @@ pub fn get_attesters_and_proposer( + (*skip_count as usize) + proposer_count; assert!(ideal_validator_count >= 2, "ideal_validator_count must be >=2"); - if ideal_validator_count > active_validator_count { - return ( - shuffled_validator_indicies[0..active_validator_count - 1].to_vec(), - shuffled_validator_indicies[active_validator_count - 1]); - } else { - return ( - shuffled_validator_indicies[0..ideal_validator_count - 1].to_vec(), - shuffled_validator_indicies[ideal_validator_count - 1]); + /* + * If there are adequate validators to allocate a full set of assesters and + * a proposer, then do so. Otherwise, the amount of attesters will need to be + * validator_count - 1. + */ + match ideal_validator_count > active_validator_count { + true => { + /* + * The active validator count is too low. + */ + warn!(log, "active validator count is low"; + "active_validator_count" => active_validator_count, + "ideal_validator_count" => ideal_validator_count); + (shuffled_validator_indicies[0..active_validator_count - 1].to_vec(), + shuffled_validator_indicies[active_validator_count - 1]) + } + false => { + /* + * The active validator count is adequate. + */ + (shuffled_validator_indicies[0..ideal_validator_count - 1].to_vec(), + shuffled_validator_indicies[ideal_validator_count - 1]) + } } }