MCPcopy
hub / github.com/canopy-network/canopy / SetValidator

Method SetValidator

fsm/validator.go:182–194  ·  view source on GitHub ↗

SetValidator() upserts a Validator object into the state

(validator *Validator)

Source from the content-addressed store, hash-verified

180
181// SetValidator() upserts a Validator object into the state
182func (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

Callers 15

SlashValidatorMethod · 0.95
HandleMessageStakeMethod · 0.95
SetValidatorsMethod · 0.95
UpdateValidatorStakeMethod · 0.95
SetValidatorUnstakingMethod · 0.95
SetValidatorPausedMethod · 0.95
SetValidatorUnpausedMethod · 0.95
TestGetCommitteeMembersFunction · 0.80
TestSetGetCommitteesFunction · 0.80
TestUpdateCommitteesFunction · 0.80

Calls 4

marshalValidatorMethod · 0.95
SetMethod · 0.95
NewAddressFromBytesFunction · 0.92
KeyForValidatorFunction · 0.85

Tested by 15

TestGetCommitteeMembersFunction · 0.64
TestSetGetCommitteesFunction · 0.64
TestUpdateCommitteesFunction · 0.64
TestUpdateDelegatesFunction · 0.64
TestDeleteDelegatesFunction · 0.64
TestGetTopDelegatesFunction · 0.64
TestHandleMessageFunction · 0.64
TestHandleMessageStakeFunction · 0.64
TestHandleByzantineFunction · 0.64