iotex-core: github.com/iotexproject/iotex-core/consensus/scheme Index | Files | Directories

package scheme

import "github.com/iotexproject/iotex-core/consensus/scheme"

Index

Package Files

errors.go noop.go scheme.go standalone.go

Variables

var (
    // ErrNotImplemented indicates the method is not implemented yet
    ErrNotImplemented = errors.New("not implemented")
)

type Broadcast Uses

type Broadcast func(msg proto.Message) error

Broadcast sends a broadcast message to the whole network

type BroadcastCB Uses

type BroadcastCB func(*block.Block) error

BroadcastCB defines the callback to publish the consensus result

type ConsensusDoneCB Uses

type ConsensusDoneCB func(*block.Block) error

ConsensusDoneCB defines the callback when consensus is reached

type ConsensusMetrics Uses

type ConsensusMetrics struct {
    LatestEpoch         uint64
    LatestHeight        uint64
    LatestDelegates     []string
    LatestBlockProducer string
    Candidates          []string
}

ConsensusMetrics contains consensus metrics to expose

type CreateBlockCB Uses

type CreateBlockCB func() (*block.Block, error)

CreateBlockCB defines the callback to create a new block

type Noop Uses

type Noop struct {
}

Noop is the consensus scheme that does NOT create blocks

func (*Noop) Activate Uses

func (n *Noop) Activate(_ bool)

Activate is not implemented for noop scheme

func (*Noop) Active Uses

func (n *Noop) Active() bool

Active is always true for noop scheme

func (*Noop) Calibrate Uses

func (n *Noop) Calibrate(uint64)

Calibrate triggers an event to calibrate consensus context

func (*Noop) HandleConsensusMsg Uses

func (n *Noop) HandleConsensusMsg(*iotextypes.ConsensusMessage) error

HandleConsensusMsg handles incoming consensus message

func (*Noop) Metrics Uses

func (n *Noop) Metrics() (ConsensusMetrics, error)

Metrics is not implemented for noop scheme

func (*Noop) Start Uses

func (n *Noop) Start(_ context.Context) error

Start does nothing here

func (*Noop) Stop Uses

func (n *Noop) Stop(_ context.Context) error

Stop does nothing here

func (*Noop) ValidateBlockFooter Uses

func (n *Noop) ValidateBlockFooter(*block.Block) error

ValidateBlockFooter validates the block footer

type Scheme Uses

type Scheme interface {
    lifecycle.StartStopper

    HandleConsensusMsg(msg *iotextypes.ConsensusMessage) error
    Calibrate(uint64)
    ValidateBlockFooter(*block.Block) error
    Metrics() (ConsensusMetrics, error)
    Activate(bool)
    Active() bool
}

Scheme is the interface that consensus schemes should implement

func NewNoop Uses

func NewNoop() Scheme

NewNoop creates a Noop struct

func NewStandalone Uses

func NewStandalone(create CreateBlockCB, commit ConsensusDoneCB, pub BroadcastCB, bc blockchain.Blockchain, interval time.Duration) Scheme

NewStandalone creates a Standalone struct.

type Standalone Uses

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

Standalone is the consensus scheme that periodically create blocks

func (*Standalone) Activate Uses

func (s *Standalone) Activate(_ bool)

Activate is not implemented for standalone scheme

func (*Standalone) Active Uses

func (s *Standalone) Active() bool

Active is always true for standalone scheme

func (*Standalone) Calibrate Uses

func (s *Standalone) Calibrate(uint64)

Calibrate triggers an event to calibrate consensus context

func (*Standalone) HandleConsensusMsg Uses

func (s *Standalone) HandleConsensusMsg(msg *iotextypes.ConsensusMessage) error

HandleConsensusMsg handles incoming consensus message

func (*Standalone) Metrics Uses

func (s *Standalone) Metrics() (ConsensusMetrics, error)

Metrics is not implemented for standalone scheme

func (*Standalone) Start Uses

func (s *Standalone) Start(ctx context.Context) error

Start starts the service for a standalone

func (*Standalone) Stop Uses

func (s *Standalone) Stop(ctx context.Context) error

Stop stops the service for a standalone

func (*Standalone) ValidateBlockFooter Uses

func (s *Standalone) ValidateBlockFooter(*block.Block) error

ValidateBlockFooter validates signatures in block footer

type TellPeerCB Uses

type TellPeerCB func(proto.Message) error

TellPeerCB defines the callback to tell (which is a unicast) message to peers on P2P network

Directories

PathSynopsis
rolldpos

Package scheme imports 12 packages (graph) and is imported by 3 packages. Updated 2019-08-18. Refresh now. Tools for package owners.