MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / saveValidatorsInfo

Method saveValidatorsInfo

state/store.go:556–584  ·  view source on GitHub ↗

saveValidatorsInfo persists the validator set. `height` is the effective height for which the validator is responsible for signing. It should be called from s.Save(), right before the state itself is persisted.

(height, lastHeightChanged int64, valSet *types.ValidatorSet)

Source from the content-addressed store, hash-verified

554// signing. It should be called from s.Save(), right before the state itself is
555// persisted.
556func (store dbStore) saveValidatorsInfo(height, lastHeightChanged int64, valSet *types.ValidatorSet) error {
557 if lastHeightChanged > height {
558 return errors.New("lastHeightChanged cannot be greater than ValidatorsInfo height")
559 }
560 valInfo := &tmstate.ValidatorsInfo{
561 LastHeightChanged: lastHeightChanged,
562 }
563 // Only persist validator set if it was updated or checkpoint height (see
564 // valSetCheckpointInterval) is reached.
565 if height == lastHeightChanged || height%valSetCheckpointInterval == 0 {
566 pv, err := valSet.ToProto()
567 if err != nil {
568 return err
569 }
570 valInfo.ValidatorSet = pv
571 }
572
573 bz, err := valInfo.Marshal()
574 if err != nil {
575 return err
576 }
577
578 err = store.db.Set(calcValidatorsKey(height), bz)
579 if err != nil {
580 return err
581 }
582
583 return nil
584}
585
586//-----------------------------------------------------------------------------
587

Callers 3

saveMethod · 0.95
BootstrapMethod · 0.95
SaveValidatorsInfoFunction · 0.95

Calls 4

MarshalMethod · 0.95
calcValidatorsKeyFunction · 0.85
SetMethod · 0.65
ToProtoMethod · 0.45

Tested by 1

SaveValidatorsInfoFunction · 0.76