sim

package
v0.2.6-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenLayers

func GenLayers(g *Generator, seqs ...Sequence) []types.LayerID

GenLayers produces sequence of layers using all configurators.

Types

type GenOpt

type GenOpt func(*Generator)

GenOpt for configuring Generator.

func WithLayerSize

func WithLayerSize(size uint32) GenOpt

WithLayerSize configures average layer size.

func WithLogger

func WithLogger(logger log.Log) GenOpt

WithLogger configures logger.

func WithPath

func WithPath(path string) GenOpt

WithPath configures path for persistent databases.

func WithSeed

func WithSeed(seed int64) GenOpt

WithSeed configures seed for Generator. By default 0 is used.

type Generator

type Generator struct {
	State State
	// contains filtered or unexported fields
}

Generator for layers of blocks.

func New

func New(opts ...GenOpt) *Generator

New creates Generator instance.

func (*Generator) Next

func (g *Generator) Next(opts ...NextOpt) types.LayerID

Next generates next layer.

func (*Generator) Setup

func (g *Generator) Setup(opts ...SetupOpt)

Setup should be called before running Next.

type NextOpt

type NextOpt func(*nextConf)

NextOpt is for configuring layer generator.

func WithNextReorder

func WithNextReorder(delay uint32) NextOpt

WithNextReorder configures when reordered layer should be returned. Examples: Next() Next(WithNextReorder(1)) Next() 1 3 2 Next() Next(WithNextReorder(2)) Next() Next() 1 3 4 2

So the Next layer with WithNextReorder will be delayed exactly by `delay` value.

func WithVoteGenerator

func WithVoteGenerator(gen VotesGenerator) NextOpt

WithVoteGenerator declares vote generator for a layer.

func WithoutInputVector

func WithoutInputVector() NextOpt

WithoutInputVector will prevent from saving input vector.

type Sequence

type Sequence struct {
	Length int
	Opts   []NextOpt
}

Sequence of layers with same configuration.

func WithSequence

func WithSequence(lth int, opts ...NextOpt) Sequence

WithSequence creates Sequence object.

type SetupOpt

type SetupOpt func(g *setupConf)

SetupOpt configures setup.

func WithSetupMinerRange

func WithSetupMinerRange(low, high int) SetupOpt

WithSetupMinerRange number of miners will be selected between low and high values.

func WithSetupUnitsRange

func WithSetupUnitsRange(low, high int) SetupOpt

WithSetupUnitsRange adjusts units of the ATXs, which will directly affect block weight.

type State

type State struct {
	MeshDB *mesh.DB
	AtxDB  *activation.DB
}

State is state that can be used by tortoise.

type VotesGenerator

type VotesGenerator func(rng *rand.Rand, layers []*types.Layer, i int) Voting

VotesGenerator allows to replace default votes generator. TODO(dshulyak) what is the best way to encapsulate all configuration that is required to generate votes?

type Voting

type Voting struct {
	Base                      types.BlockID
	Support, Against, Abstain []types.BlockID
}

Voting contains blocks voting.

func PerfectVoting

func PerfectVoting(rng *rand.Rand, layers []*types.Layer, _ int) Voting

PerfectVoting selects base block from previous layer and supports all blocks from previous layer. used by default.

Jump to

Keyboard shortcuts

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