qbft

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RoundStateName = map[int32]string{
	0: "NotStarted",
	1: "Proposal",
	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 specqbft.Height) atomic.Value

NewHeight returns a new height

func NewRound

func NewRound(round specqbft.Round) atomic.Value

NewRound returns a new round

func ReportDecided

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

ReportDecided reports on a decided message

Types

type InstanceConfig

type InstanceConfig struct {
	RoundChangeDurationSeconds float32
	LeaderProposalDelaySeconds 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 = iota
	RoundStateReady
	RoundStateProposal
	RoundStatePrepare
	RoundStateCommit
	RoundStateChangeRound
	RoundStateDecided
	RoundStateStopped
)

RoundState values

type State

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

State holds an iBFT state, thread safe

func (*State) GetHeight

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

GetHeight returns the height of the state

func (*State) GetIdentifier

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

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() specqbft.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) GetProposalAcceptedForCurrentRound added in v0.3.2

func (s *State) GetProposalAcceptedForCurrentRound() *specqbft.SignedMessage

GetProposalAcceptedForCurrentRound returns proposal accepted for current round

func (*State) GetRound

func (s *State) GetRound() specqbft.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