SetValidator() upserts a Validator object into the state
(validator *Validator)
| 180 | |
| 181 | // SetValidator() upserts a Validator object into the state |
| 182 | func (s *StateMachine) SetValidator(validator *Validator) (err lib.ErrorI) { |
| 183 | // covert the validator object to bytes |
| 184 | bz, err := s.marshalValidator(validator) |
| 185 | if err != nil { |
| 186 | return |
| 187 | } |
| 188 | // set the bytes under a key for validator using a specific 'validator address' |
| 189 | if err = s.Set(KeyForValidator(crypto.NewAddressFromBytes(validator.Address)), bz); err != nil { |
| 190 | return |
| 191 | } |
| 192 | // exit |
| 193 | return |
| 194 | } |
| 195 | |
| 196 | // UpdateValidatorStake() updates the stake of the validator object in state - updating the corresponding committees and supply |
| 197 | // NOTE: new stake amount must be GTE the previous stake amount |