election

package
v0.0.0-...-59e56fa Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Election

type Election struct {
	logger.Instance
	// contains filtered or unexported fields
}

Election is cached data of election algorithm.

func New

func New(
	validators *pos.Validators,
	frameToDecide idx.Frame,
	forklessCauseFn ForklessCauseFn,
	getFrameRoots GetFrameRootsFn,
) *Election

New election context

func (*Election) DebugStateHash

func (el *Election) DebugStateHash() common.Hash

DebugStateHash may be used in tests to match election state

func (*Election) ProcessRoot

func (el *Election) ProcessRoot(newRoot RootAndSlot) (*Res, error)

ProcessRoot calculates Atropos votes only for the new root. If this root observes that the current election is decided, then return decided Atropos

func (*Election) Reset

func (el *Election) Reset(validators *pos.Validators, frameToDecide idx.Frame)

Reset erases the current election state, prepare for new election frame

func (*Election) String

func (el *Election) String(voters []hash.Event) string

@param (optional) voters is roots to print votes for. May be nil @return election summary in a human readable format

type ForklessCauseFn

type ForklessCauseFn func(a hash.Event, b hash.Event) bool

ForklessCauseFn returns true if event A is forkless caused by event B

type GetFrameRootsFn

type GetFrameRootsFn func(f idx.Frame) []RootAndSlot

GetFrameRootsFn returns all the roots in the specified frame

type Res

type Res struct {
	Frame   idx.Frame
	Atropos hash.Event
}

Res defines the final election result, i.e. decided frame

type RootAndSlot

type RootAndSlot struct {
	ID   hash.Event
	Slot Slot
}

RootAndSlot specifies concrete root of slot.

type Slot

type Slot struct {
	Frame     idx.Frame
	Validator idx.StakerID
}

Slot specifies a root slot {addr, frame}. Normal validators can have only one root with this pair. Due to a fork, different roots may occupy the same slot

Jump to

Keyboard shortcuts

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