core

package
v0.0.0-...-ef263ed Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	MessageConstructor
	Verifier

	// BuildProposal builds a new block proposal
	BuildProposal(blockNumber uint64) []byte

	// InsertBlock inserts a proposal with the specified committed seals
	InsertBlock(proposal []byte, committedSeals []*messages.CommittedSeal)

	// ID returns the validator's ID
	ID() []byte

	// MaximumFaultyNodes returns the maximum number of faulty nodes based
	// on the validator set.
	MaximumFaultyNodes() uint64

	// Quorum returns what is the quorum size for the
	// specified block height.
	Quorum(blockHeight uint64) uint64
}

Backend defines an interface all backend implementations need to implement

type IBFT

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

IBFT represents a single instance of the IBFT state machine

func NewIBFT

func NewIBFT(
	log Logger,
	backend Backend,
	transport Transport,
) *IBFT

NewIBFT creates a new instance of the IBFT consensus protocol

func (*IBFT) AddMessage

func (i *IBFT) AddMessage(message *proto.Message)

AddMessage adds a new message to the IBFT message system

func (*IBFT) ExtendRoundTimeout

func (i *IBFT) ExtendRoundTimeout(amount time.Duration)

ExtendRoundTimeout extends each round's timer by the specified amount.

func (*IBFT) RunSequence

func (i *IBFT) RunSequence(ctx context.Context, h uint64)

RunSequence runs the IBFT sequence for the specified height

type Logger

type Logger interface {
	Info(msg string, args ...interface{})
	Debug(msg string, args ...interface{})
	Error(msg string, args ...interface{})
}

type MessageConstructor

type MessageConstructor interface {
	// BuildPrePrepareMessage builds a PREPREPARE message based on the passed in proposal
	BuildPrePrepareMessage(
		proposal []byte,
		certificate *proto.RoundChangeCertificate,
		view *proto.View,
	) *proto.Message

	// BuildPrepareMessage builds a PREPARE message based on the passed in proposal
	BuildPrepareMessage(proposalHash []byte, view *proto.View) *proto.Message

	// BuildCommitMessage builds a COMMIT message based on the passed in proposal
	BuildCommitMessage(proposalHash []byte, view *proto.View) *proto.Message

	// BuildRoundChangeMessage builds a ROUND_CHANGE message based on the passed in proposal
	BuildRoundChangeMessage(
		proposal []byte,
		certificate *proto.PreparedCertificate,
		view *proto.View,
	) *proto.Message
}

MessageConstructor defines a message constructor interface

type Messages

type Messages interface {
	// Messages modifiers //
	AddMessage(message *proto.Message)
	PruneByHeight(height uint64)

	// Messages fetchers //
	GetValidMessages(
		view *proto.View,
		messageType proto.MessageType,
		isValid func(*proto.Message) bool,
	) []*proto.Message
	GetMostRoundChangeMessages(minRound, height uint64) []*proto.Message

	// Messages subscription handlers //
	Subscribe(details messages.SubscriptionDetails) *messages.Subscription
	Unsubscribe(id messages.SubscriptionID)
}

type Transport

type Transport interface {
	// Multicast multicasts the message to other peers
	Multicast(message *proto.Message)
}

Transport defines an interface the node uses to communicate with other peers

type Verifier

type Verifier interface {
	// IsValidBlock checks if the proposed block is child of parent
	IsValidBlock(block []byte) bool

	// IsValidSender checks if signature is from sender
	IsValidSender(msg *proto.Message) bool

	// IsProposer checks if the passed in ID is the Proposer for current view (sequence, round)
	IsProposer(id []byte, height, round uint64) bool

	// IsValidProposalHash checks if the hash matches the proposal
	IsValidProposalHash(proposal, hash []byte) bool

	// IsValidCommittedSeal checks if the seal for the proposal is valid
	IsValidCommittedSeal(proposal []byte, committedSeal *messages.CommittedSeal) bool
}

Verifier defines the verifier interface

Jump to

Keyboard shortcuts

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