consensus

package
v1.4.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbciApp added in v1.4.0

type AbciApp abci.Accumulator

func (*AbciApp) Check added in v1.4.0

func (a *AbciApp) Check(req *CheckRequest) (*CheckResponse, error)

func (*AbciApp) Commit added in v1.4.0

func (a *AbciApp) Commit(req *CommitRequest) (*CommitResponse, error)

func (*AbciApp) Execute added in v1.4.0

func (a *AbciApp) Execute(req *ExecuteRequest) (*ExecuteResponse, error)

func (*AbciApp) Info added in v1.4.0

func (a *AbciApp) Info(*InfoRequest) (*InfoResponse, error)

func (*AbciApp) Init added in v1.4.0

func (a *AbciApp) Init(req *InitRequest) (*InitResponse, error)

type App

type BlockProposal added in v1.4.0

type BlockProposal struct {
	LeaderProposal
	Index     uint64
	Time      time.Time
	Envelopes []*messaging.Envelope
}

func (*BlockProposal) Equal added in v1.4.0

func (b *BlockProposal) Equal(c *BlockProposal) bool

type BlockResults added in v1.4.0

type BlockResults struct {
	MessageResults   []*protocol.TransactionStatus
	ValidatorUpdates []*execute.ValidatorUpdate
}

func (*BlockResults) Equal added in v1.4.0

func (b *BlockResults) Equal(c *BlockResults) bool

type Capture added in v1.4.0

type Capture[V Message] []V

func (*Capture[V]) Receive added in v1.4.0

func (r *Capture[V]) Receive(messages ...Message) ([]Message, error)

type CheckRequest

type CheckRequest struct {
	Context  context.Context
	Envelope *messaging.Envelope
	New      bool
}

type CheckResponse

type CheckResponse struct {
	Results []*protocol.TransactionStatus
}

type CommitRequest added in v1.4.0

type CommitRequest struct {
	Block any
}

type CommitResponse added in v1.4.0

type CommitResponse struct {
	Hash [32]byte
}

type CommitResult added in v1.4.0

type CommitResult struct {
	Hash [32]byte
}

type ConsensusError added in v1.4.0

type ConsensusError[V any] struct {
	Message      string
	Mine, Theirs V
}

A ConsensusError is produced when nodes produce conflicting results.

func (*ConsensusError[V]) Error added in v1.4.0

func (e *ConsensusError[V]) Error() string

type Dispatcher added in v1.4.0

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

func NewDispatcher added in v1.4.0

func NewDispatcher(router routing.Router) *Dispatcher

func (*Dispatcher) Receive added in v1.4.0

func (d *Dispatcher) Receive(messages ...Message) ([]Message, error)

Receive returns the queued messages.

func (*Dispatcher) Send added in v1.4.0

func (d *Dispatcher) Send(context.Context) <-chan error

Send does nothing.

func (*Dispatcher) Submit added in v1.4.0

func (d *Dispatcher) Submit(ctx context.Context, dest *url.URL, envelope *messaging.Envelope) error

Submit adds an envelope to the queue.

type ExecuteHookFunc added in v1.2.10

type ExecuteHookFunc = func(*Node, execute.BlockParams, []*messaging.Envelope) (_ []*messaging.Envelope, keepHook bool)

type ExecuteRequest added in v1.2.10

type ExecuteRequest struct {
	Params    execute.BlockParams
	Envelopes []*messaging.Envelope
}

type ExecuteResponse added in v1.2.10

type ExecuteResponse struct {
	Block   any
	Results []*protocol.TransactionStatus
	Updates []*execute.ValidatorUpdate
}

type ExecutedBlock added in v1.4.0

type ExecutedBlock struct {
	Network string
	Node    [32]byte
}

type ExecutorApp

type ExecutorApp struct {
	Executor execute.Executor
	Restore  RestoreFunc
	EventBus *events.Bus
}

func (*ExecutorApp) Check

func (a *ExecutorApp) Check(req *CheckRequest) (*CheckResponse, error)

func (*ExecutorApp) Commit added in v1.4.0

func (a *ExecutorApp) Commit(req *CommitRequest) (*CommitResponse, error)

func (*ExecutorApp) Execute added in v1.4.0

func (a *ExecutorApp) Execute(req *ExecuteRequest) (*ExecuteResponse, error)

func (*ExecutorApp) Info

func (a *ExecutorApp) Info(*InfoRequest) (*InfoResponse, error)

func (*ExecutorApp) Init

func (a *ExecutorApp) Init(req *InitRequest) (*InitResponse, error)

type Hub added in v1.4.0

type Hub interface {
	Register(module Module)
	Send(...Message) error
	With(modules ...Module) Hub
}

A Hub distributes messages to modules.

type InfoRequest

type InfoRequest struct{}

type InfoResponse

type InfoResponse struct {
	LastBlock *execute.BlockParams
	LastHash  [32]byte
}

type InitRequest

type InitRequest struct {
	Snapshot   ioutil.SectionReader
	Validators []*execute.ValidatorUpdate
}

type InitResponse

type InitResponse struct {
	Hash       []byte
	Validators []*execute.ValidatorUpdate
}

type LeaderProposal added in v1.4.0

type LeaderProposal struct {
	Leader [32]byte
}

type Message added in v1.4.0

type Message interface {
	// contains filtered or unexported methods
}

A Message is a message sent between modules.

type Module added in v1.4.0

type Module interface {
	// Receive processes messages, potentially mutating the state of the module
	// and returning messages to broadcast.
	Receive(...Message) ([]Message, error)
}

A Module is a component of a consensus network.

type Node

type Node struct {

	// SkipProposalCheck skips checking the proposed block.
	SkipProposalCheck bool

	// IgnoreDeliverResults ignores inconsistencies in the result of DeliverTx
	// (the results of transactions and signatures).
	IgnoreDeliverResults bool

	// IgnoreCommitResults ignores inconsistencies in the result of Commit (the
	// root hash of the BPT).
	IgnoreCommitResults bool
	// contains filtered or unexported fields
}

func NewNode

func NewNode(ctx context.Context, network string, key ed25519.PrivateKey, app App) *Node

func (*Node) Info

func (n *Node) Info(req *InfoRequest) (*InfoResponse, error)

func (*Node) Init

func (n *Node) Init(req *InitRequest) (*InitResponse, error)

func (*Node) Receive added in v1.4.0

func (n *Node) Receive(messages ...Message) ([]Message, error)

Receive implements [Message.Receive].

func (*Node) SetExecuteHook added in v1.2.10

func (n *Node) SetExecuteHook(hook ExecuteHookFunc)

func (*Node) SetRecorder added in v1.2.10

func (n *Node) SetRecorder(rec Recorder)

func (*Node) Status added in v1.2.10

func (n *Node) Status(*StatusRequest) (*StatusResponse, error)

type Recorder

type Recorder interface {
	DidInit(snapshot ioutil.SectionReader) error
	DidExecuteBlock(state execute.BlockState, submissions []*messaging.Envelope) error
}

type Response

type Response interface {
	Message
	// contains filtered or unexported methods
}

type RestoreFunc added in v1.2.10

type RestoreFunc func(ioutil.SectionReader) error

type SimpleHub added in v1.4.0

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

SimpleHub is a simple implementation of Hub.

func NewSimpleHub added in v1.4.0

func NewSimpleHub(ctx context.Context) *SimpleHub

func (*SimpleHub) Register added in v1.4.0

func (s *SimpleHub) Register(module Module)

func (*SimpleHub) Send added in v1.4.0

func (s *SimpleHub) Send(messages ...Message) error

func (*SimpleHub) With added in v1.4.0

func (s *SimpleHub) With(modules ...Module) Hub

type StartBlock added in v1.4.0

type StartBlock struct{}

StartBlock starts a block.

type StatusRequest added in v1.2.10

type StatusRequest struct{}

type StatusResponse added in v1.2.10

type StatusResponse struct {
	BlockIndex uint64
	BlockTime  time.Time
}

type Submission

type Submission struct {
	Network  string
	Envelope *messaging.Envelope
	Pretend  bool
}

type SubmissionResponse

type SubmissionResponse struct {
	Results []*protocol.TransactionStatus
}

func (*SubmissionResponse) Equal

Jump to

Keyboard shortcuts

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