bp

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Max

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

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 corresponding to idx.

func (*Cluster) Has

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

Has reports whether c includes id or not

func (*Cluster) Size

func (c *Cluster) Size() uint16

Size returns c.size.

func (*Cluster) Update

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

Update updates old cluster index by using ids.

type ClusterMember

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

ClusterMember is an interface which corresponds to BP member update.

type Index

type Index uint16

Index is a type for a block producer index.

func (Index) IsNil

func (idx Index) IsNil() bool

IsNil reports whether idx is nil or not.

type Snapshot

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

Snapshot represents the set of the elected BP at refBlockNo.

func NewSnapshot

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

NewSnapshot returns a Snapshot corresponding to blockNo and period.

func (*Snapshot) Key

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

Key returns the properly prefixed key corresponding to s.

func (*Snapshot) Value

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

Value returns s.list.

type Snapshots

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

Snapshots is a map from block no to *Snapshot.

func NewSnapshots

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

NewSnapshots returns a new Snapshots.

func (*Snapshots) AddSnapshot

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

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

func (*Snapshots) NeedToRefresh

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

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

func (*Snapshots) Size

func (sn *Snapshots) Size() uint16

func (*Snapshots) UpdateCluster

func (sn *Snapshots) UpdateCluster(blockNo types.BlockNo) (s []string)

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