user

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bid

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

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

func CalculateX

func CalculateX(d []byte, m []byte) Bid

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 NewBidList

func NewBidList(db database.DB) (*BidList, error)

func ReconstructBidListSubset

func ReconstructBidListSubset(pl []byte) (BidList, *prerror.PrError)

ReconstructBidListSubset will turn a slice of bytes into a BidList.

func (*BidList) AddBid

func (b *BidList) AddBid(bid Bid)

AddBid will add a bid to the BidList.

func (*BidList) Contains

func (b *BidList) Contains(bid Bid) bool

Contains checks if the BidList contains a specified Bid.

func (*BidList) RemoveBid

func (b *BidList) RemoveBid(bid Bid)

RemoveBid will iterate over a BidList to remove a specified bid.

func (*BidList) RemoveExpired

func (b *BidList) RemoveExpired(round uint64)

RemoveExpired iterates over a BidList to remove expired bids.

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) *prerror.PrError

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

type Keys

type Keys struct {
	BLSPubKey      *bls.PublicKey
	BLSPubKeyBytes []byte
	BLSSecretKey   *bls.SecretKey
	EdPubKey       *ed25519.PublicKey
	EdPubKeyBytes  []byte
	EdSecretKey    *ed25519.PrivateKey
}

Keys are the keys used during consensus

func NewKeysFromBytes

func NewKeysFromBytes(seed []byte) (Keys, error)

func NewKeysFromReader

func NewKeysFromReader(r io.Reader) (Keys, error)

func NewRandKeys

func NewRandKeys() (Keys, error)

NewRandKeys will generate and return new bls and ed25519 keys to be used in consensus

type Member

type Member struct {
	PublicKeyEd  ed25519.PublicKey
	PublicKeyBLS bls.PublicKey
	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.

type Provisioners

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

Provisioners is a slice of Members, and makes up the current provisioner committee. It implements sort.Interface

func NewProvisioners

func NewProvisioners(db database.DB) (*Provisioners, uint64, error)

NewProvisioners returns an initialized Provisioners struct.

func (*Provisioners) AddMember

func (p *Provisioners) AddMember(pubKeyEd, pubKeyBLS []byte, amount, startHeight, endHeight uint64) error

AddMember will add a Member to the Provisioners by using the bytes of a BLS public key.

func (*Provisioners) CreateVotingCommittee

func (p *Provisioners) CreateVotingCommittee(round, totalWeight 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.

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) Remove

func (p *Provisioners) Remove(pubKeyBLS []byte) bool

Remove a Member, designated by their BLS public key.

func (*Provisioners) RemoveExpired

func (p *Provisioners) RemoveExpired(round uint64) uint64

func (*Provisioners) Size

func (p *Provisioners) Size(round uint64) int

Size returns the amount of Members contained within a Provisioners struct.

type VotingCommittee

type VotingCommittee struct {
	sortedset.Set
}

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