core

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2019 License: GPL-3.0 Imports: 8 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertVoteToAddress

func ConvertVoteToAddress(votes []*Vote) []types.Address

func NewAlgo

func NewAlgo(info *GroupInfo) *algo

Types

type Algo

type Algo interface {
	ShuffleVotes(votes []*Vote, hashH *ledger.HashHeight) []*Vote
	FilterVotes(votes []*Vote, hashH *ledger.HashHeight) []*Vote
	FilterSimple(votes []*Vote) []*Vote
}

type ByBalance

type ByBalance []*Vote

func (ByBalance) Len

func (a ByBalance) Len() int

func (ByBalance) Less

func (a ByBalance) Less(i, j int) bool

func (ByBalance) Swap

func (a ByBalance) Swap(i, j int)

type ConsensusReader

type ConsensusReader interface {
	PeriodTime() (uint64, error)
	TimeToIndex(time time.Time) (uint64, error)
	// return
	VoteDetails(startIndex, endIndex uint64, register *types.Registration, r stateCh) (*Detail, error)
}

func NewReader

func NewReader(genesisTime time.Time, info *types.ConsensusGroupInfo) ConsensusReader

type Detail

type Detail struct {
	PlanNum   uint64 // member plan cnt
	ActualNum uint64 // member actual cnt
	//top100, index: nodeName: balance
	PeriodM map[uint64]*PeriodDetails
}

type GroupInfo

type GroupInfo struct {
	types.ConsensusGroupInfo

	PlanInterval uint64
	// contains filtered or unexported fields
}

func NewGroupInfo

func NewGroupInfo(genesisTime time.Time, info types.ConsensusGroupInfo) *GroupInfo

func (*GroupInfo) GenETime

func (self *GroupInfo) GenETime(index uint64) time.Time

func (*GroupInfo) GenPlan

func (self *GroupInfo) GenPlan(index uint64, members []*Vote) []*MemberPlan

func (*GroupInfo) GenPlanByAddress

func (self *GroupInfo) GenPlanByAddress(index uint64, members []types.Address) []*MemberPlan

func (*GroupInfo) GenSTime

func (self *GroupInfo) GenSTime(index uint64) time.Time

func (*GroupInfo) GenVoteTime

func (self *GroupInfo) GenVoteTime(index uint64) time.Time

func (*GroupInfo) String

func (self *GroupInfo) String() string

func (*GroupInfo) Time2Index

func (self *GroupInfo) Time2Index(t time.Time) uint64

type MemberPlan

type MemberPlan struct {
	STime  time.Time
	ETime  time.Time
	Member types.Address
	Name   string
}

type PeriodDetails

type PeriodDetails struct {
	ActualNum uint64 // actual block num in period
	VoteMap   map[string]*big.Int
}

type Vote

type Vote struct {
	Name    string
	Addr    types.Address
	Balance *big.Int
}

func CalVotes

func CalVotes(info *GroupInfo, block ledger.HashHeight, rw stateCh) ([]*Vote, error)

func GenVote

func GenVote(snapshotHash types.Hash, registration *types.Registration, infos []*types.VoteInfo, id types.TokenTypeId, rw stateCh) *Vote

Jump to

Keyboard shortcuts

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