CONTRACT: Returned ValidatorsInfo can be mutated.
(db dbm.DB, height int64)
| 527 | |
| 528 | // CONTRACT: Returned ValidatorsInfo can be mutated. |
| 529 | func loadValidatorsInfo(db dbm.DB, height int64) (*tmstate.ValidatorsInfo, error) { |
| 530 | buf, err := db.Get(calcValidatorsKey(height)) |
| 531 | if err != nil { |
| 532 | return nil, err |
| 533 | } |
| 534 | |
| 535 | if len(buf) == 0 { |
| 536 | return nil, errors.New("value retrieved from db is empty") |
| 537 | } |
| 538 | |
| 539 | v := new(tmstate.ValidatorsInfo) |
| 540 | err = v.Unmarshal(buf) |
| 541 | if err != nil { |
| 542 | // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED |
| 543 | tmos.Exit(fmt.Sprintf(`LoadValidators: Data has been corrupted or its spec has changed: |
| 544 | %v\n`, err)) |
| 545 | } |
| 546 | // TODO: ensure that buf is completely read. |
| 547 | |
| 548 | return v, nil |
| 549 | } |
| 550 | |
| 551 | // saveValidatorsInfo persists the validator set. |
| 552 | // |
no test coverage detected