creator

package
v0.0.0-...-fc88c08 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package creator contains the implementation of Creator together with functions for serializing and deserializing new epoch proofs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EpochProof

func EpochProof(pu gomel.Preunit, wtk *tss.WeakThresholdKey) bool

EpochProof checks if the given preunit is a proof that a new epoch started.

func MakeConsistent

func MakeConsistent(parents []gomel.Unit)

MakeConsistent ensures that the set of parents follows "parent consistency rule". Modifies the provided unit slice in place. Parent consistency rule means that unit's i-th parent cannot be lower (in a level sense) than i-th parent of any other of that units parents. In other words, units seen from U "directly" (as parents) cannot be below the ones seen "indirectly" (as parents of parents).

func NewProofBuilder

func NewProofBuilder(conf config.Config, log zerolog.Logger) func(gomel.EpochID) EpochProofBuilder

NewProofBuilder creates an instance of the EpochProofBuilder type.

Types

type Creator

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

Creator is a component responsible for producing new units. It reads units produced by other committee members from some external channel (aka unit belt) and stores the ones with the highest level as possible parents (candidates). Whenever there are enough parents to produce a unit on a new level, Creator collects data from its DataSource, and random source data using the provided function, then builds, signs and sends (using a function given to the constructor) a new unit.

func New

func New(
	conf config.Config,
	dataSource core.DataSource,
	send func(gomel.Unit),
	rsData func(int, []gomel.Unit, gomel.EpochID) []byte,
	epochProofBuilder func(gomel.EpochID) EpochProofBuilder,
	log zerolog.Logger,
) *Creator

New constructs a creator that uses provided config, data source and logger. send function is called on each created unit. rsData provides random source data for the given level, parents and epoch.

func NewForEpoch

func NewForEpoch(
	conf config.Config,
	dataSource core.DataSource,
	send func(gomel.Unit),
	rsData func(int, []gomel.Unit, gomel.EpochID) []byte,
	epochProofBuilder func(gomel.EpochID) EpochProofBuilder,
	epoch gomel.EpochID,
	log zerolog.Logger,

) *Creator

NewForEpoch constructs a creator that uses provided config, data source and logger. send function is called on each created unit. rsData provides random source data for the given level, parents and epoch. It starts producing units for a given epoch.

func (*Creator) CreateUnits

func (cr *Creator) CreateUnits(unitBelt, lastTiming <-chan gomel.Unit, alerter gomel.Alerter)

CreateUnits executes the main loop of the creator. Units appearing on unitBelt are examined and stored to be used as parents of future units. When there are enough new parents, a new unit is produced. lastTiming is a channel on which the last timing unit of each epoch is expected to appear. This method is stopped by closing unitBelt channel.

type EpochProofBuilder

type EpochProofBuilder interface {
	// Verify checks if given unit is a valid proof of epoch pu.EpochID()-1.
	Verify(gomel.Preunit) bool
	// TryBuilding attempts to construct an epoch-proof.
	TryBuilding(gomel.Unit) core.Data
	// BuildShare creates our share of the epoch-proof.
	BuildShare(lastTimingUnit gomel.Unit) core.Data
}

EpochProofBuilder is a type responsible for building and verifying so called epoch-proofs.

Jump to

Keyboard shortcuts

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