consensus

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2024 The Accumulate Authors

Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualMessage added in v1.4.0

func EqualMessage(a, b Message) bool

EqualMessage is used to compare the values of the union

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                `json:"index,omitempty" form:"index" query:"index" validate:"required"`
	Time      time.Time             `json:"time,omitempty" form:"time" query:"time" validate:"required"`
	Envelopes []*messaging.Envelope `json:"envelopes,omitempty" form:"envelopes" query:"envelopes" validate:"required"`
	// contains filtered or unexported fields
}

func (*BlockProposal) Copy added in v1.4.0

func (v *BlockProposal) Copy() *BlockProposal

func (*BlockProposal) CopyAsInterface added in v1.4.0

func (v *BlockProposal) CopyAsInterface() interface{}

func (*BlockProposal) Equal added in v1.4.0

func (v *BlockProposal) Equal(u *BlockProposal) bool

func (*BlockProposal) IsValid added in v1.4.0

func (v *BlockProposal) IsValid() error

func (*BlockProposal) MarshalBinary added in v1.4.0

func (v *BlockProposal) MarshalBinary() ([]byte, error)

func (*BlockProposal) MarshalJSON added in v1.4.0

func (v *BlockProposal) MarshalJSON() ([]byte, error)

func (*BlockProposal) UnmarshalBinary added in v1.4.0

func (v *BlockProposal) UnmarshalBinary(data []byte) error

func (*BlockProposal) UnmarshalBinaryFrom added in v1.4.0

func (v *BlockProposal) UnmarshalBinaryFrom(rd io.Reader) error

func (*BlockProposal) UnmarshalJSON added in v1.4.0

func (v *BlockProposal) UnmarshalJSON(data []byte) error

type BlockResults added in v1.4.0

type BlockResults struct {
	MessageResults   []*protocol.TransactionStatus `json:"messageResults,omitempty" form:"messageResults" query:"messageResults" validate:"required"`
	ValidatorUpdates []*ValidatorUpdate            `json:"validatorUpdates,omitempty" form:"validatorUpdates" query:"validatorUpdates" validate:"required"`
	// contains filtered or unexported fields
}

func (*BlockResults) Copy added in v1.4.0

func (v *BlockResults) Copy() *BlockResults

func (*BlockResults) CopyAsInterface added in v1.4.0

func (v *BlockResults) CopyAsInterface() interface{}

func (*BlockResults) Equal added in v1.4.0

func (v *BlockResults) Equal(u *BlockResults) bool

func (*BlockResults) IsValid added in v1.4.0

func (v *BlockResults) IsValid() error

func (*BlockResults) MarshalBinary added in v1.4.0

func (v *BlockResults) MarshalBinary() ([]byte, error)

func (*BlockResults) MarshalJSON added in v1.4.0

func (v *BlockResults) MarshalJSON() ([]byte, error)

func (*BlockResults) UnmarshalBinary added in v1.4.0

func (v *BlockResults) UnmarshalBinary(data []byte) error

func (*BlockResults) UnmarshalBinaryFrom added in v1.4.0

func (v *BlockResults) UnmarshalBinaryFrom(rd io.Reader) error

func (*BlockResults) UnmarshalJSON added in v1.4.0

func (v *BlockResults) UnmarshalJSON(data []byte) error

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 `json:"hash,omitempty" form:"hash" query:"hash" validate:"required"`
	// contains filtered or unexported fields
}

func (*CommitResult) Copy added in v1.4.0

func (v *CommitResult) Copy() *CommitResult

func (*CommitResult) CopyAsInterface added in v1.4.0

func (v *CommitResult) CopyAsInterface() interface{}

func (*CommitResult) Equal added in v1.4.0

func (v *CommitResult) Equal(u *CommitResult) bool

func (*CommitResult) IsValid added in v1.4.0

func (v *CommitResult) IsValid() error

func (*CommitResult) MarshalBinary added in v1.4.0

func (v *CommitResult) MarshalBinary() ([]byte, error)

func (*CommitResult) MarshalJSON added in v1.4.0

func (v *CommitResult) MarshalJSON() ([]byte, error)

func (*CommitResult) UnmarshalBinary added in v1.4.0

func (v *CommitResult) UnmarshalBinary(data []byte) error

func (*CommitResult) UnmarshalBinaryFrom added in v1.4.0

func (v *CommitResult) UnmarshalBinaryFrom(rd io.Reader) error

func (*CommitResult) UnmarshalJSON added in v1.4.0

func (v *CommitResult) UnmarshalJSON(data []byte) error

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 EnvelopeSubmitted added in v1.4.0

type EnvelopeSubmitted struct {
	Results []*protocol.TransactionStatus `json:"results,omitempty" form:"results" query:"results" validate:"required"`
	// contains filtered or unexported fields
}

func (*EnvelopeSubmitted) Copy added in v1.4.0

func (*EnvelopeSubmitted) CopyAsInterface added in v1.4.0

func (v *EnvelopeSubmitted) CopyAsInterface() interface{}

func (*EnvelopeSubmitted) Equal added in v1.4.0

func (*EnvelopeSubmitted) IsValid added in v1.4.0

func (v *EnvelopeSubmitted) IsValid() error

func (*EnvelopeSubmitted) MarshalBinary added in v1.4.0

func (v *EnvelopeSubmitted) MarshalBinary() ([]byte, error)

func (*EnvelopeSubmitted) MarshalJSON added in v1.4.0

func (v *EnvelopeSubmitted) MarshalJSON() ([]byte, error)

func (*EnvelopeSubmitted) Type added in v1.4.0

func (*EnvelopeSubmitted) Type() messageType

func (*EnvelopeSubmitted) UnmarshalBinary added in v1.4.0

func (v *EnvelopeSubmitted) UnmarshalBinary(data []byte) error

func (*EnvelopeSubmitted) UnmarshalBinaryFrom added in v1.4.0

func (v *EnvelopeSubmitted) UnmarshalBinaryFrom(rd io.Reader) error

func (*EnvelopeSubmitted) UnmarshalFieldsFrom added in v1.4.0

func (v *EnvelopeSubmitted) UnmarshalFieldsFrom(reader *encoding.Reader) error

func (*EnvelopeSubmitted) UnmarshalJSON added in v1.4.0

func (v *EnvelopeSubmitted) UnmarshalJSON(data []byte) error

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   `json:"network,omitempty" form:"network" query:"network" validate:"required"`
	Node    [32]byte `json:"node,omitempty" form:"node" query:"node" validate:"required"`
	// contains filtered or unexported fields
}

func (*ExecutedBlock) Copy added in v1.4.0

func (v *ExecutedBlock) Copy() *ExecutedBlock

func (*ExecutedBlock) CopyAsInterface added in v1.4.0

func (v *ExecutedBlock) CopyAsInterface() interface{}

func (*ExecutedBlock) Equal added in v1.4.0

func (v *ExecutedBlock) Equal(u *ExecutedBlock) bool

func (*ExecutedBlock) IsValid added in v1.4.0

func (v *ExecutedBlock) IsValid() error

func (*ExecutedBlock) MarshalBinary added in v1.4.0

func (v *ExecutedBlock) MarshalBinary() ([]byte, error)

func (*ExecutedBlock) MarshalJSON added in v1.4.0

func (v *ExecutedBlock) MarshalJSON() ([]byte, error)

func (*ExecutedBlock) Type added in v1.4.0

func (*ExecutedBlock) Type() messageType

func (*ExecutedBlock) UnmarshalBinary added in v1.4.0

func (v *ExecutedBlock) UnmarshalBinary(data []byte) error

func (*ExecutedBlock) UnmarshalBinaryFrom added in v1.4.0

func (v *ExecutedBlock) UnmarshalBinaryFrom(rd io.Reader) error

func (*ExecutedBlock) UnmarshalFieldsFrom added in v1.4.0

func (v *ExecutedBlock) UnmarshalFieldsFrom(reader *encoding.Reader) error

func (*ExecutedBlock) UnmarshalJSON added in v1.4.0

func (v *ExecutedBlock) UnmarshalJSON(data []byte) error

type ExecutorApp

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

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)

func (*ExecutorApp) SetRecorder added in v1.4.0

func (a *ExecutorApp) SetRecorder(rec Recorder)

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 `json:"leader,omitempty" form:"leader" query:"leader" validate:"required"`
	// contains filtered or unexported fields
}

func (*LeaderProposal) Copy added in v1.4.0

func (v *LeaderProposal) Copy() *LeaderProposal

func (*LeaderProposal) CopyAsInterface added in v1.4.0

func (v *LeaderProposal) CopyAsInterface() interface{}

func (*LeaderProposal) Equal added in v1.4.0

func (v *LeaderProposal) Equal(u *LeaderProposal) bool

func (*LeaderProposal) IsValid added in v1.4.0

func (v *LeaderProposal) IsValid() error

func (*LeaderProposal) MarshalBinary added in v1.4.0

func (v *LeaderProposal) MarshalBinary() ([]byte, error)

func (*LeaderProposal) MarshalJSON added in v1.4.0

func (v *LeaderProposal) MarshalJSON() ([]byte, error)

func (*LeaderProposal) UnmarshalBinary added in v1.4.0

func (v *LeaderProposal) UnmarshalBinary(data []byte) error

func (*LeaderProposal) UnmarshalBinaryFrom added in v1.4.0

func (v *LeaderProposal) UnmarshalBinaryFrom(rd io.Reader) error

func (*LeaderProposal) UnmarshalJSON added in v1.4.0

func (v *LeaderProposal) UnmarshalJSON(data []byte) error

type Message added in v1.4.0

type Message interface {
	encoding.UnionValue

	Type() messageType
	// contains filtered or unexported methods
}

A Message is a message sent between modules.

func CopyMessage added in v1.4.0

func CopyMessage(v Message) Message

CopyMessage copies a Message.

func NewMessage added in v1.4.0

func NewMessage(typ messageType) (Message, error)

NewMessage creates a new Message for the specified messageType.

func UnmarshalMessage added in v1.4.0

func UnmarshalMessage(data []byte) (Message, error)

UnmarshalMessage unmarshals a Message.

func UnmarshalMessageFrom added in v1.4.0

func UnmarshalMessageFrom(rd io.Reader) (Message, error)

UnmarshalMessageFrom unmarshals a Message.

func UnmarshalMessageJSON added in v1.4.0

func UnmarshalMessageJSON(data []byte) (Message, error)

UnmarshalMessageJson unmarshals a Message.

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 NetworkMessage added in v1.4.0

type NetworkMessage interface {
	Message
	PartitionID() string
}

A NetworkMessage is a message that is specific to a 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 NodeMessage added in v1.4.0

type NodeMessage interface {
	NetworkMessage
	SenderID() [32]byte
}

nodeMessages are passed between nodes.

type Recorder

type Recorder interface {
	DidInit(snapshot ioutil.SectionReader) error
	DidReceiveMessages([]Message) error
	DidCommitBlock(state execute.BlockState) error
}

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 {
	// contains filtered or unexported fields
}

func (*StartBlock) Copy added in v1.4.0

func (v *StartBlock) Copy() *StartBlock

func (*StartBlock) CopyAsInterface added in v1.4.0

func (v *StartBlock) CopyAsInterface() interface{}

func (*StartBlock) Equal added in v1.4.0

func (v *StartBlock) Equal(u *StartBlock) bool

func (*StartBlock) IsValid added in v1.4.0

func (v *StartBlock) IsValid() error

func (*StartBlock) MarshalBinary added in v1.4.0

func (v *StartBlock) MarshalBinary() ([]byte, error)

func (*StartBlock) MarshalJSON added in v1.4.0

func (v *StartBlock) MarshalJSON() ([]byte, error)

func (*StartBlock) Type added in v1.4.0

func (*StartBlock) Type() messageType

func (*StartBlock) UnmarshalBinary added in v1.4.0

func (v *StartBlock) UnmarshalBinary(data []byte) error

func (*StartBlock) UnmarshalBinaryFrom added in v1.4.0

func (v *StartBlock) UnmarshalBinaryFrom(rd io.Reader) error

func (*StartBlock) UnmarshalFieldsFrom added in v1.4.0

func (v *StartBlock) UnmarshalFieldsFrom(reader *encoding.Reader) error

func (*StartBlock) UnmarshalJSON added in v1.4.0

func (v *StartBlock) UnmarshalJSON(data []byte) error

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 SubmitEnvelope added in v1.4.0

type SubmitEnvelope struct {
	Network  string              `json:"network,omitempty" form:"network" query:"network" validate:"required"`
	Envelope *messaging.Envelope `json:"envelope,omitempty" form:"envelope" query:"envelope" validate:"required"`
	Pretend  bool                `json:"pretend,omitempty" form:"pretend" query:"pretend" validate:"required"`
	// contains filtered or unexported fields
}

func (*SubmitEnvelope) Copy added in v1.4.0

func (v *SubmitEnvelope) Copy() *SubmitEnvelope

func (*SubmitEnvelope) CopyAsInterface added in v1.4.0

func (v *SubmitEnvelope) CopyAsInterface() interface{}

func (*SubmitEnvelope) Equal added in v1.4.0

func (v *SubmitEnvelope) Equal(u *SubmitEnvelope) bool

func (*SubmitEnvelope) IsValid added in v1.4.0

func (v *SubmitEnvelope) IsValid() error

func (*SubmitEnvelope) MarshalBinary added in v1.4.0

func (v *SubmitEnvelope) MarshalBinary() ([]byte, error)

func (*SubmitEnvelope) MarshalJSON added in v1.4.0

func (v *SubmitEnvelope) MarshalJSON() ([]byte, error)

func (*SubmitEnvelope) PartitionID added in v1.4.0

func (s *SubmitEnvelope) PartitionID() string

func (*SubmitEnvelope) Type added in v1.4.0

func (*SubmitEnvelope) Type() messageType

func (*SubmitEnvelope) UnmarshalBinary added in v1.4.0

func (v *SubmitEnvelope) UnmarshalBinary(data []byte) error

func (*SubmitEnvelope) UnmarshalBinaryFrom added in v1.4.0

func (v *SubmitEnvelope) UnmarshalBinaryFrom(rd io.Reader) error

func (*SubmitEnvelope) UnmarshalFieldsFrom added in v1.4.0

func (v *SubmitEnvelope) UnmarshalFieldsFrom(reader *encoding.Reader) error

func (*SubmitEnvelope) UnmarshalJSON added in v1.4.0

func (v *SubmitEnvelope) UnmarshalJSON(data []byte) error

type ValidatorUpdate added in v1.4.0

type ValidatorUpdate struct {
	Type      protocol.SignatureType `json:"type,omitempty" form:"type" query:"type" validate:"required"`
	PublicKey []byte                 `json:"publicKey,omitempty" form:"publicKey" query:"publicKey" validate:"required"`
	Power     int64                  `json:"power,omitempty" form:"power" query:"power" validate:"required"`
	// contains filtered or unexported fields
}

func (*ValidatorUpdate) Copy added in v1.4.0

func (v *ValidatorUpdate) Copy() *ValidatorUpdate

func (*ValidatorUpdate) CopyAsInterface added in v1.4.0

func (v *ValidatorUpdate) CopyAsInterface() interface{}

func (*ValidatorUpdate) Equal added in v1.4.0

func (v *ValidatorUpdate) Equal(u *ValidatorUpdate) bool

func (*ValidatorUpdate) IsValid added in v1.4.0

func (v *ValidatorUpdate) IsValid() error

func (*ValidatorUpdate) MarshalBinary added in v1.4.0

func (v *ValidatorUpdate) MarshalBinary() ([]byte, error)

func (*ValidatorUpdate) MarshalJSON added in v1.4.0

func (v *ValidatorUpdate) MarshalJSON() ([]byte, error)

func (*ValidatorUpdate) UnmarshalBinary added in v1.4.0

func (v *ValidatorUpdate) UnmarshalBinary(data []byte) error

func (*ValidatorUpdate) UnmarshalBinaryFrom added in v1.4.0

func (v *ValidatorUpdate) UnmarshalBinaryFrom(rd io.Reader) error

func (*ValidatorUpdate) UnmarshalJSON added in v1.4.0

func (v *ValidatorUpdate) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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