types

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action[V Hashable[H], H Hash, A Addr] interface {
	// contains filtered or unexported methods
}

type Addr

type Addr interface {
	~[20]byte | felt.Felt
}

type BroadcastPrecommit

type BroadcastPrecommit[H Hash, A Addr] Precommit[H, A]

type BroadcastPrevote

type BroadcastPrevote[H Hash, A Addr] Prevote[H, A]

type BroadcastProposal

type BroadcastProposal[V Hashable[H], H Hash, A Addr] Proposal[V, H, A]

type Hash

type Hash interface {
	~[32]byte | felt.Felt
}

type Hashable

type Hashable[H Hash] interface {
	Hash() H
}

Hashable's Hash() is used as ID()

type Height

type Height uint

type Message

type Message[V Hashable[H], H Hash, A Addr] interface {
	MsgType() MessageType
	GetHeight() Height
}

type MessageHeader

type MessageHeader[A Addr] struct {
	Height Height `cbor:"height"`
	Round  Round  `cbor:"round"`
	Sender A      `cbor:"sender"`
}

type MessageType

type MessageType uint8

MessageType represents the type of message stored in the WAL.

const (
	MessageTypeProposal MessageType = iota
	MessageTypePrevote
	MessageTypePrecommit
	MessageTypeTimeout
	MessageTypeUnknown
)

func (MessageType) String

func (m MessageType) String() string

String returns the string representation of the MessageType.

type Messages

type Messages[V Hashable[H], H Hash, A Addr] struct {
	Proposals  map[Height]map[Round]map[A]Proposal[V, H, A]
	Prevotes   map[Height]map[Round]map[A]Prevote[H, A]
	Precommits map[Height]map[Round]map[A]Precommit[H, A]
}

Todo: would the following representation of message be better:

  height -> round -> address -> ID -> Message
How would we keep track of nil votes? In golan map key cannot be nil.
It is not easy to calculate a zero value when dealing with generics.

func NewMessages

func NewMessages[V Hashable[H], H Hash, A Addr]() Messages[V, H, A]

func (*Messages[V, H, A]) AddPrecommit

func (m *Messages[V, H, A]) AddPrecommit(p Precommit[H, A]) bool

func (*Messages[V, H, A]) AddPrevote

func (m *Messages[V, H, A]) AddPrevote(p Prevote[H, A]) bool

func (*Messages[V, H, A]) AddProposal

func (m *Messages[V, H, A]) AddProposal(p Proposal[V, H, A]) bool

Todo: ensure duplicated messages are ignored.

func (*Messages[V, H, A]) AllMessages

func (m *Messages[V, H, A]) AllMessages(h Height, r Round) (map[A]Proposal[V, H, A], map[A]Prevote[H, A],
	map[A]Precommit[H, A],
)

func (*Messages[V, H, A]) DeleteHeightMessages

func (m *Messages[V, H, A]) DeleteHeightMessages(h Height)

type Precommit

type Precommit[H Hash, A Addr] Vote[H, A]

func (Precommit[H, A]) GetHeight

func (p Precommit[H, A]) GetHeight() Height

func (Precommit[H, A]) MsgType

func (p Precommit[H, A]) MsgType() MessageType

type Prevote

type Prevote[H Hash, A Addr] Vote[H, A]

func (Prevote[H, A]) GetHeight

func (p Prevote[H, A]) GetHeight() Height

func (Prevote[H, A]) MsgType

func (p Prevote[H, A]) MsgType() MessageType

type Proposal

type Proposal[V Hashable[H], H Hash, A Addr] struct {
	MessageHeader[A]
	ValidRound Round `cbor:"valid_round"`
	Value      *V    `cbor:"value"`
}

func (Proposal[V, H, A]) GetHeight

func (p Proposal[V, H, A]) GetHeight() Height

func (Proposal[V, H, A]) MsgType

func (p Proposal[V, H, A]) MsgType() MessageType

type Round

type Round int

type ScheduleTimeout

type ScheduleTimeout Timeout

type Step

type Step uint8
const (
	StepPropose Step = iota
	StepPrevote
	StepPrecommit
)

func (Step) String

func (s Step) String() string

type Timeout

type Timeout struct {
	Step   Step
	Height Height
	Round  Round
	// contains filtered or unexported fields
}

func (Timeout) GetHeight

func (t Timeout) GetHeight() Height

func (Timeout) MsgType

func (t Timeout) MsgType() MessageType

type Vote

type Vote[H Hash, A Addr] struct {
	MessageHeader[A]
	ID *H `cbor:"id"`
}

type VotingPower

type VotingPower uint

Jump to

Keyboard shortcuts

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