committee

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: GPL-3.0 Imports: 24 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive added in v0.2.1

type Archive interface {
	HeightBefore(time.Time) (uint64, error)
	// Buckets returns a list of Bucket of a given height
	Buckets(uint64) ([]*types.Bucket, error)
	// Registrations returns a list of Registration of a given height
	Registrations(uint64) ([]*types.Registration, error)
	// MintTime returns the mint time of a given height
	MintTime(uint64) (time.Time, error)
	// PutPoll puts one poll record
	PutPoll(uint64, time.Time, []*types.Registration, []*types.Bucket) error
	// PutPolls puts multiple poll record
	PutPolls([]uint64, []time.Time, [][]*types.Registration, [][]*types.Bucket) error
	// TipHeight returns the tip height stored in archive
	TipHeight() (uint64, error)
	// Start starts the archive
	Start(context.Context) error
	// Stop stops the archive
	Stop(context.Context) error
}

Archive stores registrations, buckets, and other data

func NewArchive added in v0.2.1

func NewArchive(newDB *sql.DB, startHeight uint64, interval uint64, oldDB db.KVStoreWithNamespace) (Archive, error)

NewArchive creates a new arch of poll

type CalcGravityChainHeight added in v0.1.5

type CalcGravityChainHeight func(uint64) (uint64, error)

CalcGravityChainHeight calculates the corresponding gravity chain height for an epoch

type Committee

type Committee interface {
	// Start starts the committee service
	Start(context.Context) error
	// Stop stops the committee service
	Stop(context.Context) error
	// ResultByHeight returns the result on a specific ethereum height
	ResultByHeight(height uint64) (*types.ElectionResult, error)
	// FetchResultByHeight returns the buckets
	FetchResultByHeight(height uint64) (*types.ElectionResult, error)
	// HeightByTime returns the nearest result before time
	HeightByTime(timestamp time.Time) (uint64, error)
	// LatestHeight returns the height with latest result
	LatestHeight() uint64
	// Status returns the committee status
	Status() STATUS
}

Committee defines an interface of an election committee It could be considered as a light state db of gravity chain, that

func NewCommittee

func NewCommittee(newDB *sql.DB, cfg Config, oldDB db.KVStoreWithNamespace) (Committee, error)

NewCommittee creates a committee

type Config

type Config struct {
	NumOfRetries               uint8    `yaml:"numOfRetries"`
	GravityChainAPIs           []string `yaml:"gravityChainAPIs"`
	GravityChainHeightInterval uint64   `yaml:"gravityChainHeightInterval"`
	GravityChainStartHeight    uint64   `yaml:"gravityChainStartHeight"`
	RegisterContractAddress    string   `yaml:"registerContractAddress"`
	StakingContractAddress     string   `yaml:"stakingContractAddress"`
	PaginationSize             uint8    `yaml:"paginationSize"`
	VoteThreshold              string   `yaml:"voteThreshold"`
	ScoreThreshold             string   `yaml:"scoreThreshold"`
	SelfStakingThreshold       string   `yaml:"selfStakingThreshold"`
	CacheSize                  uint32   `yaml:"cacheSize"`
	NumOfFetchInParallel       uint8    `yaml:"numOfFetchInParallel"`
	SkipManifiedCandidate      bool     `yaml:"skipManifiedCandidate"`
	GravityChainBatchSize      uint64   `yaml:"gravityChainBatchSize"`
}

Config defines the config of the committee

type STATUS added in v0.1.4

type STATUS uint8

STATUS represents the status of committee

const (
	// STARTING stands for a starting status
	STARTING STATUS = iota
	// ACTIVE stands for an active status
	ACTIVE
	// INACTIVE stands for an inactive status
	INACTIVE
)

Jump to

Keyboard shortcuts

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