Add new method for ValidatorInductor

This commit is contained in:
Paul Hauner 2018-10-20 19:18:16 +11:00
parent b4566a776a
commit 99ce9a2dd2
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -24,6 +24,17 @@ pub enum ValidatorInductionError {
} }
impl<'a> ValidatorInductor<'a> { impl<'a> ValidatorInductor<'a> {
pub fn new(current_slot: u64, shard_count: u16, validators: &'a mut Vec<ValidatorRecord>)
-> Self
{
Self {
current_slot,
shard_count,
validators,
empty_validator_start: 0,
}
}
/// Attempt to induct a validator into the CrystallizedState. /// Attempt to induct a validator into the CrystallizedState.
/// ///
/// Returns an error if the registration is invalid, otherwise returns the index of the /// Returns an error if the registration is invalid, otherwise returns the index of the
@ -138,12 +149,10 @@ mod tests {
shard_count: u16) shard_count: u16)
-> Result<usize, ValidatorInductionError> -> Result<usize, ValidatorInductionError>
{ {
let mut inductor = ValidatorInductor { let mut inductor = ValidatorInductor::new(
current_slot, current_slot,
shard_count, shard_count,
empty_validator_start: 0, validators);
validators,
};
inductor.induct(&validator_rego) inductor.induct(&validator_rego)
} }