bp

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Max added in v0.9.0

func Max() uint16

Max returns the maximum number of active block producers.

Types

type Cluster

type Cluster struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cluster represents a cluster of block producers.

func NewCluster

func NewCluster(cdb consensus.ChainDB) (*Cluster, error)

NewCluster returns a new bp.Cluster.

func (*Cluster) BPs added in v0.9.0

func (c *Cluster) BPs() []string

BPs returns BP information about each BP in JSON.

func (*Cluster) BpID2Index

func (c *Cluster) BpID2Index(id types.PeerID) Index

BpID2Index returns the index corresponding to id.

func (*Cluster) BpIndex2ID

func (c *Cluster) BpIndex2ID(bpIdx Index) (types.PeerID, bool)

BpIndex2ID returns the ID correspinding to idx.

func (*Cluster) Has

func (c *Cluster) Has(id types.PeerID) bool

Has reports whether c includes id or not

func (*Cluster) Size added in v0.9.0

func (c *Cluster) Size() uint16

Size returns c.size.

func (*Cluster) Update added in v0.9.0

func (c *Cluster) Update(ids []string) error

Update updates old cluster index by using ids.

type ClusterMember added in v0.9.0

type ClusterMember interface {
	Size() uint16
	Update(ids []string) error
}

ClusterMember is an interface which corresponds to BP member udpate.

type Index added in v0.9.0

type Index uint16

Index is a type for a block producer index.

func (Index) IsNil added in v0.9.0

func (idx Index) IsNil() bool

IsNil reports whether idx is nil or not.

type Snapshot added in v0.9.0

type Snapshot struct {
	RefBlockNo types.BlockNo
	List       []string
}

Snapshot represents the set of the elected BP at refBlockNo.

func NewSnapshot added in v0.9.0

func NewSnapshot(blockNo types.BlockNo, bps []string) (*Snapshot, error)

NewSnapshot returns a Snapshot corresponding to blockNo and period.

func (*Snapshot) Key added in v0.9.0

func (s *Snapshot) Key() []byte

Key returns the properly prefixed key corresponding to s.

func (*Snapshot) Value added in v0.9.0

func (s *Snapshot) Value() []byte

Value returns s.list.

type Snapshots added in v0.9.0

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

Snapshots is a map from block no to *Snapshot.

func NewSnapshots added in v0.9.0

func NewSnapshots(c ClusterMember, cdb consensus.ChainDB, sdb *state.ChainStateDB) *Snapshots

NewSnapshots returns a new Snapshots.

func (*Snapshots) AddSnapshot added in v0.9.0

func (sn *Snapshots) AddSnapshot(refBlockNo types.BlockNo) ([]string, error)

AddSnapshot add a new BP list corresponding to refBlockNO to sn.

func (*Snapshots) NeedToRefresh added in v0.9.0

func (sn *Snapshots) NeedToRefresh(blockNo types.BlockNo) bool

NeedToRefresh reports whether blockNo corresponds to a BP regime change point.

func (*Snapshots) UpdateCluster added in v0.9.0

func (sn *Snapshots) UpdateCluster(blockNo types.BlockNo)

UpdateCluster updates the current BP list by the ones corresponding to blockNo.

Jump to

Keyboard shortcuts

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