payload

package
v0.0.0-...-f94ef0f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeView

type ChangeView interface {
	// NewViewNumber returns proposed view number.
	NewViewNumber() byte

	// SetNewViewNumber sets the proposed view number.
	SetNewViewNumber(view byte)

	// Timestamp returns message's timestamp.
	Timestamp() uint64

	// SetTimestamp sets message's timestamp.
	SetTimestamp(ts uint64)

	// Reason returns change view reason.
	Reason() ChangeViewReason

	// SetReason sets change view reason.
	SetReason(reason ChangeViewReason)
}

ChangeView represents dBFT ChangeView message.

func NewChangeView

func NewChangeView() ChangeView

NewChangeView returns minimal ChangeView implementation.

type ChangeViewReason

type ChangeViewReason byte

ChangeViewReason represents a view change reason code.

const (
	CVTimeout               ChangeViewReason = 0x0  // Timeout
	CVChangeAgreement       ChangeViewReason = 0x1  // ChangeAgreement
	CVTxNotFound            ChangeViewReason = 0x2  // TxNotFound
	CVTxRejectedByPolicy    ChangeViewReason = 0x3  // TxRejectedByPolicy
	CVTxInvalid             ChangeViewReason = 0x4  // TxInvalid
	CVBlockRejectedByPolicy ChangeViewReason = 0x5  // BlockRejectedByPolicy
	CVUnknown               ChangeViewReason = 0xff // Unknown
)

func (ChangeViewReason) String

func (i ChangeViewReason) String() string

type Commit

type Commit interface {
	// Signature returns commit's signature field
	// which is a block signature for the current epoch.
	Signature() []byte

	// SetSignature sets commit's signature.
	SetSignature(signature []byte)
}

Commit is an interface for dBFT Commit message.

func NewCommit

func NewCommit() Commit

NewCommit returns minimal Commit implementation.

type ConsensusPayload

type ConsensusPayload interface {

	// ValidatorIndex returns index of validator from which
	// payload was originated from.
	ValidatorIndex() uint16

	// SetValidator index sets validator index.
	SetValidatorIndex(i uint16)

	Height() uint32
	SetHeight(h uint32)

	// Hash returns 32-byte checksum of the payload.
	Hash() common.Hash
	// contains filtered or unexported methods
}

ConsensusPayload is a generic payload type which is exchanged between the nodes.

func NewConsensusPayload

func NewConsensusPayload() ConsensusPayload

NewConsensusPayload returns minimal ConsensusPayload implementation.

type MessageType

type MessageType byte

MessageType is a type for dBFT consensus messages.

const (
	ChangeViewType      MessageType = 0x00
	PrepareRequestType  MessageType = 0x20
	PrepareResponseType MessageType = 0x21
	CommitType          MessageType = 0x30
	RecoveryRequestType MessageType = 0x40
	RecoveryMessageType MessageType = 0x41
)

6 following constants enumerate all possible type of consensus message.

func (MessageType) String

func (m MessageType) String() string

String implements fmt.Stringer interface.

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 *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (Payload) EncodeBinary

func (p Payload) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

func (Payload) GetChangeView

func (m Payload) GetChangeView() ChangeView

func (Payload) GetCommit

func (m Payload) GetCommit() Commit

func (Payload) GetPrepareRequest

func (m Payload) GetPrepareRequest() PrepareRequest

func (Payload) GetPrepareResponse

func (m Payload) GetPrepareResponse() PrepareResponse

func (Payload) GetRecoveryMessage

func (m Payload) GetRecoveryMessage() RecoveryMessage

func (Payload) GetRecoveryRequest

func (m Payload) GetRecoveryRequest() RecoveryRequest

func (*Payload) Hash

func (p *Payload) Hash() common.Hash

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() interface{}

Payload implements ConsensusMessage interface.

func (Payload) PrevHash

func (p Payload) PrevHash() common.Hash

PrevHash implements ConsensusPayload interface.

func (*Payload) SetHeight

func (p *Payload) SetHeight(h uint32)

SetHeight implements ConsensusPayload interface.

func (*Payload) SetPayload

func (m *Payload) SetPayload(p interface{})

SetPayload implements ConsensusMessage interface.

func (*Payload) SetPrevHash

func (p *Payload) SetPrevHash(h common.Hash)

SetPrevHash implements ConsensusPayload interface.

func (*Payload) SetType

func (m *Payload) SetType(t MessageType)

SetType implements ConsensusMessage interface.

func (*Payload) SetValidatorIndex

func (p *Payload) SetValidatorIndex(i uint16)

SetValidatorIndex implements ConsensusPayload interface.

func (*Payload) SetVersion

func (p *Payload) SetVersion(v uint32)

SetVersion implements ConsensusPayload interface.

func (*Payload) SetViewNumber

func (m *Payload) SetViewNumber(view byte)

SetViewNumber implements ConsensusMessage interface.

func (Payload) Type

func (m Payload) Type() 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 PrepareRequest

type PrepareRequest interface {
	// Timestamp returns this message's timestamp.
	Timestamp() uint64
	// SetTimestamp sets timestamp of this message.
	SetTimestamp(ts uint64)

	// Nonce is a random nonce.
	Nonce() uint64
	// SetNonce sets Nonce.
	SetNonce(nonce uint64)

	// TransactionHashes returns hashes of all transaction in a proposed block.
	TransactionHashes() []common.Hash
	// SetTransactionHashes sets transaction's hashes.
	SetTransactionHashes(hs []common.Hash)

	// NextConsensus returns hash which is based on which validators will
	// try to agree on a block in the current epoch.
	NextConsensus() common.Address
	// SetNextConsensus sets next consensus field.
	SetNextConsensus(nc common.Address)
}

PrepareRequest represents dBFT PrepareRequest message.

func NewPrepareRequest

func NewPrepareRequest() PrepareRequest

NewPrepareRequest returns minimal prepareRequest implementation.

type PrepareResponse

type PrepareResponse interface {
	// PreparationHash returns the hash of PrepareRequest payload
	// for this epoch.
	PreparationHash() common.Hash
	// SetPreparationHash sets preparations hash.
	SetPreparationHash(h common.Hash)
}

PrepareResponse represents dBFT PrepareResponse message.

func NewPrepareResponse

func NewPrepareResponse() PrepareResponse

NewPrepareResponse returns minimal PrepareResponse implementation.

type RecoveryMessage

type RecoveryMessage interface {
	// AddPayload adds payload from this epoch to be recovered.
	AddPayload(p ConsensusPayload)
	// GetPrepareRequest returns PrepareRequest to be processed.
	GetPrepareRequest(p ConsensusPayload, validators []*keys.PublicKey, primary uint16) ConsensusPayload
	// GetPrepareResponses returns a slice of PrepareResponse in any order.
	GetPrepareResponses(p ConsensusPayload, validators []*keys.PublicKey) []ConsensusPayload
	// GetChangeView returns a slice of ChangeView in any order.
	GetChangeViews(p ConsensusPayload, validators []*keys.PublicKey) []ConsensusPayload
	// GetCommits returns a slice of Commit in any order.
	GetCommits(p ConsensusPayload, validators []*keys.PublicKey) []ConsensusPayload

	// PreparationHash returns has of PrepareRequest payload for this epoch.
	// It can be useful in case only PrepareResponse payloads were received.
	PreparationHash() *common.Hash
	// SetPreparationHash sets preparation hash.
	SetPreparationHash(h *common.Hash)
}

RecoveryMessage represents dBFT Recovery message.

func NewRecoveryMessage

func NewRecoveryMessage() RecoveryMessage

NewRecoveryMessage returns minimal RecoveryMessage implementation.

type RecoveryRequest

type RecoveryRequest interface {
	// Timestamp returns this message's timestamp.
	Timestamp() uint64
	// SetTimestamp sets this message's timestamp.
	SetTimestamp(ts uint64)
}

RecoveryRequest represents dBFT RecoveryRequest message.

func NewRecoveryRequest

func NewRecoveryRequest() RecoveryRequest

NewRecoveryRequest returns minimal RecoveryRequest implementation.

Jump to

Keyboard shortcuts

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