params

package
v0.0.0-...-caec882 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SignatureVote

type SignatureVote struct {
	Vote      *pb.Vote  `json:"vote"`
	Signature []byte    `json:"signature"`
	Time      time.Time `json:"time"`
}

type Singer

type Singer struct {
	// contains filtered or unexported fields
}

func NewSinger

func NewSinger(privKey *ecdsa.PrivateKey) *Singer

func (*Singer) Address

func (s *Singer) Address() hash.Address

func (*Singer) SignBlock

func (s *Singer) SignBlock(block *pb.Block) ([]byte, error)

func (*Singer) SignVote

func (s *Singer) SignVote(vote *pb.Vote) ([]byte, error)

type Validator

type Validator struct {
	ID      uint32           `json:"id"`
	Address hash.Address     `json:"address"`
	PubKey  *ecdsa.PublicKey `json:"pub_key"`

	Accum int64 `json:"accum"`
}

Volatile state for each Validator NOTE: The Accum is not included in Validator.Hash(); make sure to update that method if changes are made here

func NewValidator

func NewValidator(id uint32, pubKey *ecdsa.PublicKey) *Validator

func (*Validator) Copy

func (v *Validator) Copy() *Validator

Creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.

func (*Validator) VerifySignature

func (v *Validator) VerifySignature(hash hash.Hash, signature []byte) bool

type ValidatorSet

type ValidatorSet struct {
	// NOTE: persisted via reflect, must be exported.
	Validators []*Validator `json:"validators"`
	Proposer   *Validator   `json:"proposer"`
	// contains filtered or unexported fields
}

ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height. On the other hand, the .AccumPower of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety.

func NewValidatorSet

func NewValidatorSet(pubkList [][]byte) (*ValidatorSet, error)

func (*ValidatorSet) GetByAddress

func (vs *ValidatorSet) GetByAddress(address hash.Address) *Validator

func (*ValidatorSet) GetProposer

func (vs *ValidatorSet) GetProposer(height, round uint64) *Validator

GetProposer returns the current proposer. If the validator set is empty, nil is returned.

type ValidatorsSort

type ValidatorsSort []*Validator

Sort validators by address

func (ValidatorsSort) Len

func (v ValidatorsSort) Len() int

func (ValidatorsSort) Less

func (v ValidatorsSort) Less(i, j int) bool

func (ValidatorsSort) Swap

func (v ValidatorsSort) Swap(i, j int)

type VoteSet

type VoteSet struct {
	// contains filtered or unexported fields
}

func NewVoteSet

func NewVoteSet(height, round uint64, valSet *ValidatorSet) *VoteSet

func (*VoteSet) AddVote

func (vs *VoteSet) AddVote(vote *pb.Vote, signature []byte) bool

func (*VoteSet) GetVotes

func (vs *VoteSet) GetVotes(blockHash hash.Hash) []*SignatureVote

func (*VoteSet) HasTwoThirdsAny

func (vs *VoteSet) HasTwoThirdsAny() bool

func (*VoteSet) TwoThirdsMajority

func (vs *VoteSet) TwoThirdsMajority() (hash.Hash, bool)

If there was a +2/3 majority for blockID, return blockID and true. Else, return the empty BlockID{} and false.

Jump to

Keyboard shortcuts

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