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)
| 554 | // signing. It should be called from s.Save(), right before the state itself is |
| 555 | // persisted. |
| 556 | func (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 |