odra_core/validator.rs
1//! Validator related types.
2use casper_types::U512;
3
4/// ValidatorInfo contains information about a validator.
5#[derive(Clone, Debug)]
6pub struct ValidatorInfo {
7 /// The amount of tokens staked.
8 pub staked_amount: U512,
9 /// The minimum amount of tokens that must be delegated to the validator.
10 pub minimum_delegation_amount: u64
11}
12
13impl ValidatorInfo {
14 /// Creates a new ValidatorInfo with the given staked amount and minimum delegation amount.
15 pub fn new(staked_amount: U512, minimum_delegation_amount: u64) -> Self {
16 ValidatorInfo {
17 staked_amount,
18 minimum_delegation_amount
19 }
20 }
21
22 /// Sets the ValidatorInfo with the staked amount set to the given value.
23 pub fn set_staked_amount(&mut self, staked_amount: U512) {
24 self.staked_amount = staked_amount;
25 }
26
27 /// Sets the ValidatorInfo with the minimum delegation amount set to the given value.
28 pub fn set_minimum_delegation_amount(&mut self, minimum_delegation_amount: u64) {
29 self.minimum_delegation_amount = minimum_delegation_amount;
30 }
31}