header

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose added in v0.2.0

func Compose(blsPubKey bytes.Buffer, phase bytes.Buffer, hash []byte) (bytes.Buffer, error)

Compose is useful when header information is cached and there is an opportunity to avoid unnecessary allocations.

func Marshal added in v0.2.0

func Marshal(r *bytes.Buffer, ev Header) error

Marshal a Header into a Buffer.

func MarshalFields added in v0.2.0

func MarshalFields(r *bytes.Buffer, h Header) error

MarshalFields marshals the core field of the Header (i.e. Round, Step and BlockHash).

func MarshalSignableVote

func MarshalSignableVote(r *bytes.Buffer, h Header) error

MarshalSignableVote marshals the fields necessary for a Committee member to cast a Vote (namely the Round, the Step and the BlockHash). Note: UnmarshalSignableVote does not make sense as the only reason to use it would be if we could somehow revert a signature to the preimage and thus unmarshal it into a struct :P.

func Unmarshal added in v0.2.0

func Unmarshal(r *bytes.Buffer, ev *Header) error

Unmarshal unmarshals the buffer into a Header.

func UnmarshalFields added in v0.2.0

func UnmarshalFields(r *bytes.Buffer, h *Header) error

UnmarshalFields unmarshals the core field of the Header (i.e. Round, Step and BlockHash).

func VerifySignatures added in v0.2.0

func VerifySignatures(round uint64, step uint8, blockHash []byte, apk *bls.Apk, sig *bls.Signature) error

VerifySignatures verifies the BLS aggregated signature carried by consensus related messages. The signed message needs to carry information about the round, the step and the blockhash.

Types

type Header struct {
	PubKeyBLS []byte
	Round     uint64
	Step      uint8
	BlockHash []byte
}

Header is an embeddable struct representing the consensus event header fields.

func Mock added in v0.3.0

func Mock() Header

Mock a Header.

func New added in v0.3.0

func New() Header

New will create a Header instance.

func (Header) CompareRound added in v0.2.0

func (h Header) CompareRound(round uint64) Phase

CompareRound compares the actual h Header v @round returning the respective phase.

func (Header) CompareRoundAndStep added in v0.2.0

func (h Header) CompareRoundAndStep(round uint64, step uint8) Phase

CompareRoundAndStep Compare headers to establish time order.

func (Header) Copy added in v0.4.0

func (h Header) Copy() payload.Safe

Copy complies with the Safe interface.

func (Header) Equal

func (h Header) Equal(e wire.Event) bool

Equal implements wire.Event. Checks if two headers are the same.

func (Header) Sender

func (h Header) Sender() []byte

Sender implements wire.Event. Returns the BLS public key of the event sender. It is part of the consensus.Packet interface.

func (Header) State added in v0.3.0

func (h Header) State() Header

State returns the Header struct itself. It is mandate by the consensus.InternalPacket interface.

func (Header) String added in v0.3.0

func (h Header) String() string

type Phase added in v0.2.0

type Phase uint8

Phase is used to introduce a time order to the Header.

const (
	// Same indicates that headers belong to the same phase.
	Same Phase = iota
	// Before indicates that the header indicates a past event.
	Before
	// After indicates that the header indicates a future event.
	After
)

type Writer added in v0.2.0

type Writer interface {
	WriteHeader([]byte, *bytes.Buffer) error
}

Writer writes the header to a Buffer. It is an interface injected into components.

Jump to

Keyboard shortcuts

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