consensus

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 12 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]) error,
	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 NewAMEVBlock added in v0.3.0

func NewAMEVBlock(pre dbft.PreBlock[crypto.Uint256], cnData [][]byte, m int) dbft.Block[crypto.Uint256]

NewAMEVBlock returns new block based on PreBlock and additional Commit-level data collected from M consensus nodes.

func NewAMEVCommit added in v0.3.0

func NewAMEVCommit(data []byte) dbft.Commit

NewAMEVCommit returns minimal dbft.Commit implementation for anti-MEV extension.

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 NewPreBlock added in v0.3.0

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

NewPreBlock returns new preBlock.

func NewPreCommit added in v0.3.0

func NewPreCommit(data []byte) dbft.PreCommit

NewPreCommit returns minimal dbft.PreCommit 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) GetPreCommit added in v0.3.0

func (m Payload) GetPreCommit() dbft.PreCommit

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.

type Tx64 added in v0.3.0

type Tx64 uint64

func (*Tx64) Hash added in v0.3.0

func (t *Tx64) Hash() (h crypto.Uint256)

func (*Tx64) MarshalBinary added in v0.3.0

func (t *Tx64) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler interface.

func (*Tx64) UnmarshalBinary added in v0.3.0

func (t *Tx64) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnarshaler interface.

Jump to

Keyboard shortcuts

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