fn stake(&mut self, current_era: EraIndex, value: Balance) -> Result<(), &str> {
		if let Some(era_stake) = self.stakes.last_mut() {
			if era_stake.era > current_era {
				return Err("Unexpected era".into())
			}

			let new_stake_value = era_stake.staked.saturating_add(value);
			if current_era == era_stake.era {
				*era_stake = EraStake::new(new_stake_value, current_era)
			} else {
				self.stakes.push(EraStake::new(new_stake_value, current_era))
			}
		} else {
			self.stakes.push(EraStake::new(value, current_era))
		}

		Ok(())
	}
/// Stakes some value in the specified era.
///
/// User should ensure that given era is either equal or greater than the
/// latest available era in the staking info.
///
/// # Example
///
/// The following example demonstrates how internal vector changes when `stake` is called:
///
/// `stakes: [<5, 1000>, <7, 1300>]`
/// * `stake(7, 100)` will result in `[<5, 1000>, <7, 1400>]`
/// * `stake(9, 200)` will result in `[<5, 1000>, <7, 1400>, <9, 1600>]`
Stakes some value in the specified era.
User should ensure that given era is either equal or greater than the
latest available era in the staking info.
Stakes some value in the specified era . User should ensure that given era is either equal or greater than the latest available era in the staking info .
fn stake(&mut self, current_era: EraIndex, value: Balance) -> Result<(), &str> {
		if let Some(era_stake) = self.stakes.last_mut() {
			if era_stake.era > current_era {
				return Err("Unexpected era".into())
			}
			let new_stake_value = era_stake.staked.saturating_add(value);
			if current_era == era_stake.era {
				*era_stake = EraStake::new(new_stake_value, current_era)
			} else {
				self.stakes.push(EraStake::new(new_stake_value, current_era))
			}
		} else {
			self.stakes.push(EraStake::new(value, current_era))
		}
		Ok(())
	}
fn stake ( & mut self , current_era : EraIndex , value : Balance ) -> Result < ( ) , & str > { if let Some ( era_stake ) = self . stakes . last_mut ( ) { if era_stake . era > current_era { return Err ( " " . into ( ) ) } let new_stake_value = era_stake . staked . saturating_add ( value ) ; if current_era == era_stake . era { * era_stake = EraStake :: new ( new_stake_value , current_era ) } else { self . stakes . push ( EraStake :: new ( new_stake_value , current_era ) ) } } else { self . stakes . push ( EraStake :: new ( value , current_era ) ) } Ok ( ( ) ) }
Stakes some value in the specified era.
Stakes some value in the specified era .
&mut self
current_era
EraIndex
value
Balance
example
The following example demonstrates how internal vector changes when `stake` is called.


The following example demonstrates how internal vector changes when ` stake ` is called .