You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
888 B

  1. package factory
  2. import (
  3. "sort"
  4. cfg "github.com/tendermint/tendermint/config"
  5. tmtime "github.com/tendermint/tendermint/libs/time"
  6. "github.com/tendermint/tendermint/types"
  7. )
  8. func RandGenesisDoc(
  9. config *cfg.Config,
  10. numValidators int,
  11. randPower bool,
  12. minPower int64) (*types.GenesisDoc, []types.PrivValidator) {
  13. validators := make([]types.GenesisValidator, numValidators)
  14. privValidators := make([]types.PrivValidator, numValidators)
  15. for i := 0; i < numValidators; i++ {
  16. val, privVal := RandValidator(randPower, minPower)
  17. validators[i] = types.GenesisValidator{
  18. PubKey: val.PubKey,
  19. Power: val.VotingPower,
  20. }
  21. privValidators[i] = privVal
  22. }
  23. sort.Sort(types.PrivValidatorsByAddress(privValidators))
  24. return &types.GenesisDoc{
  25. GenesisTime: tmtime.Now(),
  26. InitialHeight: 1,
  27. ChainID: config.ChainID(),
  28. Validators: validators,
  29. }, privValidators
  30. }