types

package
v0.0.0-...-191b3e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EventTypeVote = "vote"

	AttributeKeyCandidate = "name"

	AttributeValueCategory = ModuleName
)

poa module event types

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "poa"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName

	// RouterKey to be used for routing msgs
	RouterKey = ModuleName

	// QuerierRoute to be used for querier msgs
	QuerierRoute = ModuleName
)
View Source
const (
	// Default percentage of votes to join the set
	DefaultQuorum uint16 = 49

	// Default maximum number of bonded validators
	DefaultMaxValidators uint16 = 100
)

Default parameter namespace

View Source
const (
	QueryValidatorPOA     = "validator-poa"
	QueryAllValidatorsPOA = "validators"
	QueryVotePOA          = "vote-poa"
	QueryAllVotesPOA      = "votes"
)

Variables

View Source
var (
	ErrEmptyValidatorAddr       = sdkerrors.Register(ModuleName, 1, "empty validator address")
	ErrBadValidatorAddr         = sdkerrors.Register(ModuleName, 2, "validator address is invalid")
	ErrNoValidatorFound         = sdkerrors.Register(ModuleName, 3, "validator does not exist")
	ErrNoAcceptedValidatorFound = sdkerrors.Register(ModuleName, 4, "accepted validator does not exist")
)
View Source
var (
	ValidatorsKey          = []byte{0x51} // prefix for each key to a validator
	ValidatorsByAddressKey = []byte{0x52} // prefix for each key to a validator
	VotesKey               = []byte{0x53} // prefix for each key to a vote
	VotesByValidatorKey    = []byte{0x54} // prefix for each key to a validator
)
View Source
var (
	NewMsgCreateValidatorPOA = msg.NewMsgCreateValidatorPOA
	NewMsgVoteValidator      = msg.NewMsgVoteValidator
)
View Source
var (
	KeyQuorum        = []byte("Quorum")
	KeyMaxValidators = []byte("MaxValidators")
)

nolint - Keys for parameter access

Functions

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for poa module

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the authority genesis parameters

Types

type GenesisState

type GenesisState struct {
	Params     Params      `json:"params" yaml:"params"`
	Validators []Validator `json:"validators" yaml:"validators"`
}

GenesisState - all authority state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState gets the raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(params Params, validators []Validator) GenesisState

NewGenesisState creates a new GenesisState instanc e

type LastValidatorPower

type LastValidatorPower struct {
	Address sdk.ValAddress
	Power   int64
}

LastValidatorPower required for validator set update logic

type MsgCreateValidatorPOA

type MsgCreateValidatorPOA = msg.MsgCreateValidatorPOA

This is a work around to allow messages to be defined in another package while allowing the hander to function as expected

type MsgVoteValidator

type MsgVoteValidator = msg.MsgVoteValidator

This is a work around to allow messages to be defined in another package while allowing the hander to function as expected

type ParamSubspace

type ParamSubspace interface {
	WithKeyTable(table params.KeyTable) params.Subspace
	Get(ctx sdk.Context, key []byte, ptr interface{})
	GetParamSet(ctx sdk.Context, ps params.ParamSet)
	SetParamSet(ctx sdk.Context, ps params.ParamSet)
}

ParamSubspace defines the expected Subspace interfacace

type Params

type Params struct {
	Quorum        uint16 `json:"quorum" yaml:"quorum"`                 // percentage of validators that need to vote
	MaxValidators uint16 `json:"max_validators" yaml:"max_validators"` // maximum number of validators (max uint16 = 65535)
}

Params - used for initializing default parameter for poa at genesis

func DefaultParams

func DefaultParams() Params

DefaultParams defines the parameters for this module

func NewParams

func NewParams(quorum uint16, maxValidators uint16) Params

NewParams creates a new Params object

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs - Implements params.ParamSet

func (Params) String

func (p Params) String() string

String implements the stringer interface for Params

type QueryValidatorParams

type QueryValidatorParams struct {
	Name string
}

QueryValidatorParams

func NewQueryValidatorParams

func NewQueryValidatorParams(name string) QueryValidatorParams

NewQueryValidatorParams

type QueryValidatorResolve

type QueryValidatorResolve struct {
	Name     string `json:"name"`
	Accepted bool   `json:"accepted"`
}

QueryValidatorResolve Queries Result Payload for a resolve query

type QueryVoteParams

type QueryVoteParams struct {
	Name  string
	Voter string
}

QueryVoteParams

func NewQueryVoteParams

func NewQueryVoteParams(name string, voter string) QueryVoteParams

NewQueryVoteParams

type QueryVoteResolve

type QueryVoteResolve struct {
	Name    string `json:"name"`
	Voter   string `json:"voter"`
	InFavor bool   `json:"in_favor"`
}

QueryVoteResolve Queries Result Payload for a resolve query

type Validator

type Validator struct {
	Name        string                   `json:"name" yaml:"name"`
	Address     sdk.ValAddress           `json:"address" yaml:"address"`
	PubKey      crypto.PubKey            `json:"pubkey" yaml:"pubkey"`
	Description stakingtypes.Description `json:"description" yaml:"description"`
	Accepted    bool                     `json:"accepted" yaml:"accepted"`
	InSet       bool                     `json:"inset" yaml:"inset"`
}

Validator - Data structure to define validators for consensus

func NewValidator

func NewValidator(name string, address sdk.ValAddress, pubKey crypto.PubKey, description stakingtypes.Description) Validator

NewValidator - initialize a new validator

func (Validator) ABCIValidatorUpdate

func (v Validator) ABCIValidatorUpdate(power int64) abci.ValidatorUpdate

ABCIValidatorUpdate returns an abci.ValidatorUpdate from a staking validator type with the full validator power

type Vote

type Vote struct {
	Voter   sdk.ValAddress `json:"voter" yaml:"voter"`
	Name    string         `json:"name" yaml:"name"`
	InFavor bool           `json:"in_favor" yaml:"in_favor"`
}

Vote - Contains data that allows validators to vote

func NewVote

func NewVote(voter sdk.ValAddress, name string, inFavor bool) Vote

NewVote

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL