user

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalBidList added in v0.2.0

func MarshalBidList(r *bytes.Buffer, bidList BidList) error

func MarshalProvisioners added in v0.2.0

func MarshalProvisioners(r *bytes.Buffer, p *Provisioners) error

Types

type Bid

type Bid struct {
	X         [32]byte
	M         [32]byte
	EndHeight uint64
}

Bid is the 32 byte X value, created from a bidding transaction amount and M.

func (Bid) Equals

func (b Bid) Equals(bid Bid) bool

Equals will return whether or not the two bids are the same.

type BidList

type BidList []Bid

BidList is a list of bid X values.

func ReconstructBidListSubset

func ReconstructBidListSubset(pl []byte) (BidList, error)

ReconstructBidListSubset will turn a slice of bytes into a BidList.

func UnmarshalBidList added in v0.2.0

func UnmarshalBidList(r *bytes.Buffer) (BidList, error)

func (BidList) Contains

func (b BidList) Contains(bid Bid) bool

Contains checks if the BidList contains a specified Bid.

func (*BidList) Remove added in v0.2.0

func (b *BidList) Remove(idx int)

func (BidList) Subset

func (b BidList) Subset(amount int) []Bid

Subset will shuffle the BidList, and returns a specified amount of bids from it.

func (BidList) ValidateBids

func (b BidList) ValidateBids(bidListSubset BidList) error

ValidateBids will check if the passed BidList subset contains valid bids.

type Member

type Member struct {
	PublicKeyEd  []byte
	PublicKeyBLS []byte
	Stakes       []Stake
}

Member contains the bytes of a provisioner's Ed25519 public key, the bytes of his BLS public key, and how much he has staked.

func (*Member) AddStake added in v0.2.0

func (m *Member) AddStake(stake Stake)

func (*Member) RemoveStake added in v0.2.0

func (m *Member) RemoveStake(idx int)

func (*Member) SubtractFromStake added in v0.2.0

func (m *Member) SubtractFromStake(amount uint64) uint64

type Provisioners

type Provisioners struct {
	Set     sortedset.Set
	Members map[string]*Member
}

Provisioners is a map of Members, and makes up the current set of provisioners.

func NewProvisioners

func NewProvisioners() *Provisioners

func UnmarshalProvisioners added in v0.2.0

func UnmarshalProvisioners(r *bytes.Buffer) (Provisioners, error)

func (Provisioners) CreateVotingCommittee

func (p Provisioners) CreateVotingCommittee(round uint64, step uint8, size int) VotingCommittee

CreateVotingCommittee will run the deterministic sortition function, which determines who will be in the committee for a given step and round. FIXME: running this with weird setup causes infinite looping (to reproduce, hardcode `3` on MockProvisioners when calling agreement.NewHelper in the agreement tests)

func (Provisioners) GenerateCommittees added in v0.2.0

func (p Provisioners) GenerateCommittees(round uint64, amount, step uint8, size int) []VotingCommittee

GenerateCommittees pre-generates an `amount` of VotingCommittee of a specified `size` from a given `step`

func (Provisioners) GetMember

func (p Provisioners) GetMember(pubKeyBLS []byte) *Member

GetMember returns a member of the provisioners from its BLS public key.

func (Provisioners) GetStake

func (p Provisioners) GetStake(pubKeyBLS []byte) (uint64, error)

GetStake will find a certain provisioner in the committee by BLS public key, and return their stake.

func (Provisioners) MemberAt

func (p Provisioners) MemberAt(i int) *Member

MemberAt returns the Member at a certain index.

func (Provisioners) SubsetSizeAt added in v0.2.0

func (p Provisioners) SubsetSizeAt(round uint64) int

SubsetSizeAt returns how many provisioners are active on a given round. This function is used to determine the correct committee size for sortition in the case where one or more provisioner stakes have not yet become active, or have just expired. Note that this function will only give an accurate result if the round given is either identical or close to the current block height, as stakes are removed soon after they expire.

func (*Provisioners) TotalWeight added in v0.2.0

func (p *Provisioners) TotalWeight() (totalWeight uint64)

type Stake added in v0.2.0

type Stake struct {
	Amount      uint64
	StartHeight uint64
	EndHeight   uint64
}

type VotingCommittee

type VotingCommittee struct {
	sortedset.Cluster
}

VotingCommittee represents a set of provisioners with voting rights at a certain point in the consensus. The set is sorted by the int value of the public key in increasing order (higher last)

func (VotingCommittee) Equal

func (v VotingCommittee) Equal(other *VotingCommittee) bool

Equal checks if two VotingCommittees are the same.

func (VotingCommittee) IsMember

func (v VotingCommittee) IsMember(pubKeyBLS []byte) bool

IsMember checks if `pubKeyBLS` is within the VotingCommittee.

func (VotingCommittee) MemberKeys

func (v VotingCommittee) MemberKeys() [][]byte

MemberKeys returns the BLS public keys of all the members in a VotingCommittee.

func (*VotingCommittee) Remove

func (v *VotingCommittee) Remove(pk []byte) bool

Remove a member from the VotingCommittee by its BLS public key.

func (VotingCommittee) Size

func (v VotingCommittee) Size() int

Size returns how many members there are in a VotingCommittee.

Jump to

Keyboard shortcuts

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