Documentation ¶
Index ¶
- Variables
- type BroadcastCB
- type ConsensusDoneCB
- type ConsensusMetrics
- type CreateBlockCB
- type Noop
- func (n *Noop) HandleBlockPropose(propose *iproto.ProposePb) error
- func (n *Noop) HandleEndorse(endorse *iproto.EndorsePb) error
- func (n *Noop) Metrics() (ConsensusMetrics, error)
- func (n *Noop) SetDoneStream(done chan bool)
- func (n *Noop) Start(_ context.Context) error
- func (n *Noop) Stop(_ context.Context) error
- type Scheme
- type Standalone
- func (n *Standalone) HandleBlockPropose(propose *iproto.ProposePb) error
- func (n *Standalone) HandleEndorse(endorse *iproto.EndorsePb) error
- func (n *Standalone) Metrics() (ConsensusMetrics, error)
- func (n *Standalone) SetDoneStream(done chan bool)
- func (n *Standalone) Start(ctx context.Context) error
- func (n *Standalone) Stop(ctx context.Context) error
- type TellPeerCB
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotImplemented indicates the method is not implemented yet ErrNotImplemented = errors.New("not implemented") )
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 LatestHeight uint64 LatestDelegates []string LatestBlockProducer string Candidates []string }
ConsensusMetrics contains consensus metrics to expose
type CreateBlockCB ¶
type CreateBlockCB func() (*blockchain.Block, error)
CreateBlockCB defines the callback to create a new block
type Noop ¶
type Noop struct { }
Noop is the consensus scheme that does NOT create blocks
func (*Noop) HandleBlockPropose ¶ added in v0.4.0
HandleBlockPropose handles incoming block propose
func (*Noop) HandleEndorse ¶ added in v0.4.0
HandleEndorse handles incoming block propose
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
SetDoneStream does nothing for Noop (only used in simulator)
type Scheme ¶
type Scheme interface { lifecycle.StartStopper HandleBlockPropose(propose *iproto.ProposePb) error HandleEndorse(endorse *iproto.EndorsePb) error SetDoneStream(chan bool) Metrics() (ConsensusMetrics, error) }
Scheme is the interface that consensus schemes should implement
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) HandleBlockPropose ¶ added in v0.4.0
func (n *Standalone) HandleBlockPropose(propose *iproto.ProposePb) error
HandleBlockPropose handles incoming block propose
func (*Standalone) HandleEndorse ¶ added in v0.4.0
func (n *Standalone) HandleEndorse(endorse *iproto.EndorsePb) error
HandleEndorse handles incoming block propose
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)
type TellPeerCB ¶
TellPeerCB defines the callback to tell (which is a unicast) message to peers on P2P network