bp

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	sync.Mutex
	// 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 v1.0.0

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

BPs returns BP information about each BP in JSON.

func (*Cluster) BpID2Index

func (c *Cluster) BpID2Index(id peer.ID) Index

BpID2Index returns the index corresponding to id.

func (*Cluster) BpIndex2ID

func (c *Cluster) BpIndex2ID(bpIdx Index) (peer.ID, bool)

BpIndex2ID returns the ID correspinding to idx.

func (*Cluster) Has

func (c *Cluster) Has(id peer.ID) bool

Has reports whether c includes id or not

func (*Cluster) Size added in v0.9.4

func (c *Cluster) Size() uint16

Size returns c.size.

func (*Cluster) Update added in v0.9.4

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

Update updates old cluster index by using ids.

type ClusterMember added in v0.9.4

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

ClusterMember is an interface which corresponds to BP member udpate.

type Index added in v0.11.0

type Index uint16

Index is a type for a block producer index.

func (Index) IsNil added in v0.11.0

func (idx Index) IsNil() bool

IsNil reports whether idx is nil or not.

type Snapshot added in v0.9.4

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

Snapshot represents the set of the elected BP at refBlockNo.

func NewSnapshot added in v0.9.4

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

NewSnapshot returns a Snapshot corresponding to blockNo and period.

func (*Snapshot) Key added in v0.9.4

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

Key returns the properly prefixed key corresponding to s.

func (*Snapshot) Value added in v0.9.4

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

Value returns s.list.

type Snapshots added in v0.9.4

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

Snapshots is a map from block no to *Snapshot.

func NewSnapshots added in v0.9.4

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

NewSnapshots returns a new Snapshots.

func (*Snapshots) AddSnapshot added in v0.9.4

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.4

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.10

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