scheme

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastCB

type BroadcastCB func(*blockchain.Block) error

BroadcastCB defines the callback to publish the consensus result

type ConsensusDoneCB

type ConsensusDoneCB func(*blockchain.Block) error

ConsensusDoneCB defines the callback when consensus is reached

type ConsensusMetrics added in v0.2.0

type ConsensusMetrics struct {
	LatestEpoch         uint64
	LatestDelegates     []net.Addr
	LatestBlockProducer net.Addr
	Candidates          []net.Addr
}

ConsensusMetrics contains consensus metrics to expose

type CreateBlockCB

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

CreateBlockCB defines the callback to create a new block

type GenerateDKGCB added in v0.2.0

type GenerateDKGCB func() (common.DKGHash, error)

GenerateDKGCB defines the callback to generate DKG bytes

type GetProposerCB added in v0.2.0

type GetProposerCB func([]net.Addr, []byte, uint64, uint64) (net.Addr, error)

GetProposerCB defines the callback to check the if itself is the the proposer for the coming round

type Noop

type Noop struct {
}

Noop is the consensus scheme that does NOT create blocks

func (*Noop) Handle

func (n *Noop) Handle(message proto.Message) error

Handle handles incoming requests

func (*Noop) Metrics added in v0.2.0

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

Metrics is not implemented for standalone scheme

func (*Noop) SetDoneStream added in v0.2.0

func (n *Noop) SetDoneStream(done chan bool)

SetDoneStream does nothing for Noop (only used in simulator)

func (*Noop) Start

func (n *Noop) Start() error

Start does nothing here

func (*Noop) Stop

func (n *Noop) Stop() error

Stop does nothing here

type Scheme

type Scheme interface {
	Start() error
	Stop() error
	Handle(msg proto.Message) error
	SetDoneStream(chan bool)
	Metrics() (ConsensusMetrics, error)
}

Scheme is the interface that consensus schemes should implement

func NewNoop

func NewNoop() Scheme

NewNoop creates a Noop struct

func NewStandalone

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

NewStandalone creates a Standalone struct.

type Standalone

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

Standalone is the consensus scheme that periodically create blocks

func (*Standalone) Handle

func (n *Standalone) Handle(message proto.Message) error

Handle handles incoming requests

func (*Standalone) Metrics added in v0.2.0

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

Metrics is not implemented for standalone scheme

func (*Standalone) SetDoneStream added in v0.2.0

func (n *Standalone) SetDoneStream(done chan bool)

SetDoneStream does nothing in Standalone (only used in simulator)

func (*Standalone) Start

func (n *Standalone) Start() error

Start starts the service for a standalone

func (*Standalone) Stop

func (n *Standalone) Stop() error

Stop stops the service for a standalone

type StartNextEpochCB added in v0.2.0

type StartNextEpochCB func(net.Addr, uint64, state.Factory, delegate.Pool) (bool, error)

StartNextEpochCB defines the callback to check if the next epoch should start

type TellPeerCB

type TellPeerCB func(proto.Message) error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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