core

package
v2.12.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package core is a generated GoMock package.

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 MockSBPStatReader added in v2.11.3

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

MockSBPStatReader is a mock of SBPStatReader interface.

func NewMockSBPStatReader added in v2.11.3

func NewMockSBPStatReader(ctrl *gomock.Controller) *MockSBPStatReader

NewMockSBPStatReader creates a new mock instance.

func (*MockSBPStatReader) DayStats added in v2.11.3

func (m *MockSBPStatReader) DayStats(startIndex, endIndex uint64) ([]*DayStats, error)

DayStats mocks base method.

func (*MockSBPStatReader) EXPECT added in v2.11.3

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSBPStatReader) GetDayTimeIndex added in v2.11.3

func (m *MockSBPStatReader) GetDayTimeIndex() TimeIndex

GetDayTimeIndex mocks base method.

func (*MockSBPStatReader) GetHourTimeIndex added in v2.11.3

func (m *MockSBPStatReader) GetHourTimeIndex() TimeIndex

GetHourTimeIndex mocks base method.

func (*MockSBPStatReader) GetNodeCount added in v2.11.3

func (m *MockSBPStatReader) GetNodeCount() int

GetNodeCount mocks base method.

func (*MockSBPStatReader) GetPeriodTimeIndex added in v2.11.3

func (m *MockSBPStatReader) GetPeriodTimeIndex() TimeIndex

GetPeriodTimeIndex mocks base method.

func (*MockSBPStatReader) GetSuccessRateByHour added in v2.11.3

func (m *MockSBPStatReader) GetSuccessRateByHour(index uint64) (map[types.Address]int32, error)

GetSuccessRateByHour mocks base method.

func (*MockSBPStatReader) HourStats added in v2.11.3

func (m *MockSBPStatReader) HourStats(startIndex, endIndex uint64) ([]*HourStats, error)

HourStats mocks base method.

func (*MockSBPStatReader) PeriodStats added in v2.11.3

func (m *MockSBPStatReader) PeriodStats(startIndex, endIndex uint64) ([]*PeriodStats, error)

PeriodStats mocks base method.

type MockSBPStatReaderMockRecorder added in v2.11.3

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

MockSBPStatReaderMockRecorder is the mock recorder for MockSBPStatReader.

func (*MockSBPStatReaderMockRecorder) DayStats added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) DayStats(startIndex, endIndex interface{}) *gomock.Call

DayStats indicates an expected call of DayStats.

func (*MockSBPStatReaderMockRecorder) GetDayTimeIndex added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) GetDayTimeIndex() *gomock.Call

GetDayTimeIndex indicates an expected call of GetDayTimeIndex.

func (*MockSBPStatReaderMockRecorder) GetHourTimeIndex added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) GetHourTimeIndex() *gomock.Call

GetHourTimeIndex indicates an expected call of GetHourTimeIndex.

func (*MockSBPStatReaderMockRecorder) GetNodeCount added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) GetNodeCount() *gomock.Call

GetNodeCount indicates an expected call of GetNodeCount.

func (*MockSBPStatReaderMockRecorder) GetPeriodTimeIndex added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) GetPeriodTimeIndex() *gomock.Call

GetPeriodTimeIndex indicates an expected call of GetPeriodTimeIndex.

func (*MockSBPStatReaderMockRecorder) GetSuccessRateByHour added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) GetSuccessRateByHour(index interface{}) *gomock.Call

GetSuccessRateByHour indicates an expected call of GetSuccessRateByHour.

func (*MockSBPStatReaderMockRecorder) HourStats added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) HourStats(startIndex, endIndex interface{}) *gomock.Call

HourStats indicates an expected call of HourStats.

func (*MockSBPStatReaderMockRecorder) PeriodStats added in v2.11.3

func (mr *MockSBPStatReaderMockRecorder) PeriodStats(startIndex, endIndex interface{}) *gomock.Call

PeriodStats indicates an expected call of PeriodStats.

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