qbft

package
v0.2.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RoundStateName = map[int32]string{
	0: "NotStarted",
	1: "PrePrepare",
	2: "Prepare",
	3: "Commit",
	4: "ChangeRound",
	5: "Decided",
	6: "Stopped",
}

RoundStateName represents the map of the round state names

Functions

func NewByteValue

func NewByteValue(val []byte) atomic.Value

NewByteValue returns a new byte value

func NewHeight

func NewHeight(height message.Height) atomic.Value

NewHeight returns a new height

func NewRound

func NewRound(round message.Round) atomic.Value

NewRound returns a new round

func ReportDecided

func ReportDecided(pk string, msg *message.SignedMessage)

ReportDecided reports on a decided message

Types

type InstanceConfig

type InstanceConfig struct {
	RoundChangeDurationSeconds   float32
	LeaderPreprepareDelaySeconds float32
}

InstanceConfig is the configuration of the instance

func DefaultConsensusParams

func DefaultConsensusParams() *InstanceConfig

DefaultConsensusParams returns the default round change duration time

type RoundState

type RoundState int32

RoundState is the state of the round

const (
	RoundStateNotStarted  RoundState = 0
	RoundStatePrePrepare  RoundState = 1
	RoundStatePrepare     RoundState = 2
	RoundStateCommit      RoundState = 3
	RoundStateChangeRound RoundState = 4
	RoundStateDecided     RoundState = 5
	RoundStateStopped     RoundState = 6
)

RoundState values

type State

type State struct {
	Stage atomic.Int32 // RoundState
	// lambda is an instance unique identifier, much like a block hash in a blockchain
	Identifier atomic.Value // message.Identifier
	// Height is an incremental number for each instance, much like a block number would be in a blockchain
	Height        atomic.Value // message.Height
	InputValue    atomic.Value // []byte
	Round         atomic.Value // message.Round
	PreparedRound atomic.Value // message.Round
	PreparedValue atomic.Value // []byte
}

State holds an iBFT state, thread safe

func (*State) GetHeight

func (s *State) GetHeight() message.Height

GetHeight returns the height of the state

func (*State) GetIdentifier

func (s *State) GetIdentifier() message.Identifier

GetIdentifier returns the identifier of the state

func (*State) GetInputValue

func (s *State) GetInputValue() []byte

GetInputValue returns the input value of the state

func (*State) GetPreparedRound

func (s *State) GetPreparedRound() message.Round

GetPreparedRound returns the prepared round of the state

func (*State) GetPreparedValue

func (s *State) GetPreparedValue() []byte

GetPreparedValue returns the prepared value of the state

func (*State) GetRound

func (s *State) GetRound() message.Round

GetRound returns the round of the state

func (*State) MarshalJSON

func (s *State) MarshalJSON() ([]byte, error)

MarshalJSON implements marshaling interface

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(data []byte) error

UnmarshalJSON implements marshaling interface

Jump to

Keyboard shortcuts

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