core

package
v2.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NORMAL                 = VoteType(0)
	SUCCESS_RATE_PROMOTION = VoteType(1)
	SUCCESS_RATE_DEMOTION  = VoteType(2)
	RANDOM_PROMOTION       = VoteType(3)
)
View Source
const (
	Line = 800000
)

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, info *SeedInfo) []*Vote
	FilterVotes(context *VoteAlgoContext) []*Vote
	FilterSimple(votes []*Vote) ([]*Vote, []*Vote)
}

type BaseStats

type BaseStats struct {
	Index uint64                      `json:"index"`
	Stats map[types.Address]*SbpStats `json:"stats"`
}

type BigInt

type BigInt struct {
	*big.Int
}

func (*BigInt) MarshalJSON

func (x *BigInt) MarshalJSON() ([]byte, error)

func (*BigInt) MarshalText

func (i *BigInt) MarshalText() ([]byte, error)

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 BySuccessRate

type BySuccessRate []*SuccessRateVote

func (BySuccessRate) Len

func (a BySuccessRate) Len() int

func (BySuccessRate) Less

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

func (BySuccessRate) Swap

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

type DayStats

type DayStats struct {
	Index uint64               `json:"index"`
	Stats map[string]*SbpStats `json:"stats"`

	VoteSum *BigInt `json:"voteSum"`
	// block total in one day
	BlockTotal uint64 `json:"blockTotal"`
}

type GroupInfo

type GroupInfo struct {
	TimeIndex
	types.ConsensusGroupInfo

	GenesisTime time.Time

	PlanInterval uint64
	// contains filtered or unexported fields
}

func NewGroupInfo

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

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

func (self GroupInfo) String() string

type HourStats

type HourStats struct {
	*BaseStats
}

type MemberPlan

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

type PeriodStats

type PeriodStats struct {
	*BaseStats
}

type SBPStatReader

type SBPStatReader interface {
	DayStats(startIndex uint64, endIndex uint64) ([]*DayStats, error)
	GetDayTimeIndex() TimeIndex

	HourStats(startIndex uint64, endIndex uint64) ([]*HourStats, error)
	GetHourTimeIndex() TimeIndex

	PeriodStats(startIndex uint64, endIndex uint64) ([]*PeriodStats, error)
	GetPeriodTimeIndex() TimeIndex

	GetSuccessRateByHour(index uint64) (map[types.Address]int32, error)
	GetNodeCount() int
}

type SbpStats

type SbpStats struct {
	Index            uint64  `json:"index"`
	BlockNum         uint64  `json:"blockNum"`
	ExceptedBlockNum uint64  `json:"exceptedBlockNum"`
	VoteCnt          *BigInt `json:"voteCnt"`
	Name             string  `json:"name"`
}

type SeedInfo

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

func NewSeedInfo

func NewSeedInfo(seed uint64) *SeedInfo

type SuccessRateVote

type SuccessRateVote struct {
	*Vote
	Rate int32
}

type TimeIndex

type TimeIndex interface {
	Index2Time(index uint64) (time.Time, time.Time)
	Time2Index(t time.Time) uint64
}

func NewTimeIndex

func NewTimeIndex(t time.Time, interval time.Duration) TimeIndex

type Vote

type Vote struct {
	Name    string
	Addr    types.Address
	Balance *big.Int
	Type    []VoteType
}

func CalVotes

func CalVotes(info types.ConsensusGroupInfo, hash types.Hash, rw stateCh) ([]*Vote, error)

type VoteAlgoContext

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

func NewVoteAlgoContext

func NewVoteAlgoContext(votes []*Vote, hashH *ledger.HashHeight, successRate map[types.Address]int32, seeds *SeedInfo) *VoteAlgoContext

type VoteType

type VoteType uint8

Jump to

Keyboard shortcuts

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