consensus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(logger *zap.Logger, key dbft.PrivateKey, pub dbft.PublicKey,
	getTx func(uint256 crypto.Uint256) dbft.Transaction[crypto.Uint256],
	getVerified func() []dbft.Transaction[crypto.Uint256],
	broadcast func(dbft.ConsensusPayload[crypto.Uint256]),
	processBlock func(dbft.Block[crypto.Uint256]),
	currentHeight func() uint32,
	currentBlockHash func() crypto.Uint256,
	getValidators func(...dbft.Transaction[crypto.Uint256]) []dbft.PublicKey,
	verifyPayload func(consensusPayload dbft.ConsensusPayload[crypto.Uint256]) error) (*dbft.DBFT[crypto.Uint256], error)

func NewBlock

func NewBlock(timestamp uint64, index uint32, prevHash crypto.Uint256, nonce uint64, txHashes []crypto.Uint256) dbft.Block[crypto.Uint256]

NewBlock returns new block.

func NewChangeView

func NewChangeView(newViewNumber byte, _ dbft.ChangeViewReason, ts uint64) dbft.ChangeView

NewChangeView returns minimal ChangeView implementation.

func NewCommit

func NewCommit(signature []byte) dbft.Commit

NewCommit returns minimal Commit implementation.

func NewConsensusPayload

func NewConsensusPayload(t dbft.MessageType, height uint32, validatorIndex uint16, viewNumber byte, consensusMessage any) dbft.ConsensusPayload[crypto.Uint256]

NewConsensusPayload returns minimal ConsensusPayload implementation.

func NewPrepareRequest

func NewPrepareRequest(ts uint64, nonce uint64, transactionsHashes []crypto.Uint256) dbft.PrepareRequest[crypto.Uint256]

NewPrepareRequest returns minimal prepareRequest implementation.

func NewPrepareResponse

func NewPrepareResponse(preparationHash crypto.Uint256) dbft.PrepareResponse[crypto.Uint256]

NewPrepareResponse returns minimal PrepareResponse implementation.

func NewRecoveryMessage

func NewRecoveryMessage(preparationHash *crypto.Uint256) dbft.RecoveryMessage[crypto.Uint256]

NewRecoveryMessage returns minimal RecoveryMessage implementation.

func NewRecoveryRequest

func NewRecoveryRequest(ts uint64) dbft.RecoveryRequest

NewRecoveryRequest returns minimal RecoveryRequest implementation.

Types

type Payload

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

Payload represents minimal payload containing all necessary fields.

func (*Payload) DecodeBinary

func (p *Payload) DecodeBinary(r *gob.Decoder) error

DecodeBinary implements Serializable interface.

func (Payload) EncodeBinary

func (p Payload) EncodeBinary(w *gob.Encoder) error

EncodeBinary implements Serializable interface.

func (Payload) GetChangeView

func (m Payload) GetChangeView() dbft.ChangeView

func (Payload) GetCommit

func (m Payload) GetCommit() dbft.Commit

func (Payload) GetPrepareRequest

func (m Payload) GetPrepareRequest() dbft.PrepareRequest[crypto.Uint256]

func (Payload) GetPrepareResponse

func (m Payload) GetPrepareResponse() dbft.PrepareResponse[crypto.Uint256]

func (Payload) GetRecoveryMessage

func (m Payload) GetRecoveryMessage() dbft.RecoveryMessage[crypto.Uint256]

func (Payload) GetRecoveryRequest

func (m Payload) GetRecoveryRequest() dbft.RecoveryRequest

func (*Payload) Hash

func (p *Payload) Hash() crypto.Uint256

Hash implements ConsensusPayload interface.

func (Payload) Height

func (p Payload) Height() uint32

Height implements ConsensusPayload interface.

func (Payload) MarshalUnsigned

func (p Payload) MarshalUnsigned() []byte

MarshalUnsigned implements ConsensusPayload interface.

func (Payload) Payload

func (m Payload) Payload() any

Payload implements ConsensusMessage interface.

func (Payload) PrevHash

func (p Payload) PrevHash() crypto.Uint256

PrevHash implements ConsensusPayload interface.

func (*Payload) SetValidatorIndex

func (p *Payload) SetValidatorIndex(i uint16)

SetValidatorIndex implements ConsensusPayload interface.

func (Payload) Type

func (m Payload) Type() dbft.MessageType

Type implements ConsensusMessage interface.

func (*Payload) UnmarshalUnsigned

func (p *Payload) UnmarshalUnsigned(data []byte) error

UnmarshalUnsigned implements ConsensusPayload interface.

func (Payload) ValidatorIndex

func (p Payload) ValidatorIndex() uint16

ValidatorIndex implements ConsensusPayload interface.

func (Payload) Version

func (p Payload) Version() uint32

Version implements ConsensusPayload interface.

func (Payload) ViewNumber

func (m Payload) ViewNumber() byte

ViewNumber implements ConsensusMessage interface.

type Serializable

type Serializable interface {
	EncodeBinary(encoder *gob.Encoder) error
	DecodeBinary(decoder *gob.Decoder) error
}

Serializable is an interface for serializing consensus messages.

Jump to

Keyboard shortcuts

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