currentstate

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentState

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

CurrentState defines the current state object in IBFT

NOTE: not thread safe, better to wrap it in mutext for concurrent use case

func NewState

func NewState() *CurrentState

NewState creates a new state with reset round messages

func (*CurrentState) AddCommitted

func (c *CurrentState) AddCommitted(msg *proto.MessageReq)

AddCommitted adds a committed message

func (*CurrentState) AddMessage

func (c *CurrentState) AddMessage(msg *proto.MessageReq)

AddMessage adds a new message to one of the following message lists: committed, prepared, roundMessages

func (*CurrentState) AddPostCommitted added in v1.2.1

func (c *CurrentState) AddPostCommitted(msg *proto.MessageReq)

func (*CurrentState) AddPrepared

func (c *CurrentState) AddPrepared(msg *proto.MessageReq)

AddPrepared adds a prepared message

func (*CurrentState) AddRoundMessage

func (c *CurrentState) AddRoundMessage(msg *proto.MessageReq) int

AddRoundMessage adds a message to the round, and returns the round message size

func (*CurrentState) Block

func (c *CurrentState) Block() *types.Block

func (*CurrentState) CalcNeedPunished

func (c *CurrentState) CalcNeedPunished(
	currentRound uint64,
	lastBlockProposer types.Address,
) (addr []types.Address)

func (*CurrentState) CalcProposer

func (c *CurrentState) CalcProposer(lastProposer types.Address)

CalcProposer calculates the proposer and sets it to the state

func (*CurrentState) CanonicalSeal added in v1.2.1

func (c *CurrentState) CanonicalSeal() *proto.MessageReq

func (*CurrentState) CleanRound

func (c *CurrentState) CleanRound(round uint64)

CleanRound deletes the specific round messages

func (*CurrentState) Clear added in v1.2.1

func (c *CurrentState) Clear(height uint64)

func (*CurrentState) Committed

func (c *CurrentState) Committed() map[types.Address]*proto.MessageReq

func (*CurrentState) ConsumeErr

func (c *CurrentState) ConsumeErr() error

ConsumeErr returns the current error, if any, and consumes it

func (*CurrentState) GetState

func (c *CurrentState) GetState() IbftState

GetState returns the current state

func (*CurrentState) HandleErr

func (c *CurrentState) HandleErr(err error)

func (*CurrentState) IsLocked

func (c *CurrentState) IsLocked() bool

func (*CurrentState) Lock

func (c *CurrentState) Lock()

func (*CurrentState) MaxFaultyNodes

func (c *CurrentState) MaxFaultyNodes() int

func (*CurrentState) MaxRound

func (c *CurrentState) MaxRound() (maxRound uint64, found bool)

func (*CurrentState) MessageTimeout

func (c *CurrentState) MessageTimeout() time.Duration

MessageTimeout returns duration for waiting message

Consider the network travel time between most validators, using validator numbers instead of rounds.

func (*CurrentState) NextRound

func (c *CurrentState) NextRound() uint64

func (*CurrentState) NumCommitted

func (c *CurrentState) NumCommitted() int

numCommitted returns the number of messages in the committed message list

func (*CurrentState) NumPrepared

func (c *CurrentState) NumPrepared() int

NumPrepared returns the number of messages in the prepared message list

func (*CurrentState) NumValid

func (c *CurrentState) NumValid() int

NumValid returns the number of required messages

func (*CurrentState) PeekError

func (c *CurrentState) PeekError() error

func (*CurrentState) Proposer

func (c *CurrentState) Proposer() types.Address

func (*CurrentState) ResetRoundMsgs

func (c *CurrentState) ResetRoundMsgs()

ResetRoundMsgs resets the prepared, committed and round messages in the current state

func (*CurrentState) Round

func (c *CurrentState) Round() uint64

func (*CurrentState) Sequence

func (c *CurrentState) Sequence() uint64

func (*CurrentState) SetAdditionalTimeout added in v1.2.1

func (c *CurrentState) SetAdditionalTimeout(d time.Duration)

SetAdditionalTimeout sets an additional timeout for potentially long builds

func (*CurrentState) SetBlock

func (c *CurrentState) SetBlock(b *types.Block)

func (*CurrentState) SetState

func (c *CurrentState) SetState(s IbftState)

SetState sets the current state

func (*CurrentState) SetValidators

func (c *CurrentState) SetValidators(validators []types.Address)

func (*CurrentState) SetView

func (c *CurrentState) SetView(view *proto.View)

func (*CurrentState) Unlock

func (c *CurrentState) Unlock()

func (*CurrentState) Validators

func (c *CurrentState) Validators() []types.Address

func (*CurrentState) View

func (c *CurrentState) View() *proto.View

type IbftState

type IbftState uint32
const (
	AcceptState IbftState = iota
	RoundChangeState
	ValidateState // including prepare, commit, and post commit state stage
	CommitState   // committed
	FinState      // finish current sequence
)

Define the states in IBFT

func (IbftState) String

func (i IbftState) String() string

String returns the string representation of the passed in state

Jump to

Keyboard shortcuts

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