header

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 4 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 wire.Event) 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 wire.Event) 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 (Header) CompareRound added in v0.2.0

func (h Header) CompareRound(round uint64) Phase

func (Header) CompareRoundAndStep added in v0.2.0

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

Compare headers to establish time order

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.

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