tdag

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ASCIIschemeForEach

func ASCIIschemeForEach(
	scheme string,
	callback ForEachEvent,
) (
	nodes []idx.ValidatorID,
	events map[idx.ValidatorID]dag.Events,
	names map[string]dag.Event,
)

ASCIIschemeToDAG parses events from ASCII-scheme for test purpose. Use joiners ║ ╬ ╠ ╣ ╫ ╚ ╝ ╩ and optional fillers ─ ═ to draw ASCII-scheme. Result:

  • nodes is an array of node addresses;
  • events maps node address to array of its events;
  • names maps human readable name to the event;

func ASCIIschemeToDAG

func ASCIIschemeToDAG(
	scheme string,
) (
	nodes []idx.ValidatorID,
	events map[idx.ValidatorID]dag.Events,
	names map[string]dag.Event,
)

func ByParents

func ByParents(ee dag.Events) (res dag.Events)

ByParents returns events topologically ordered by parent dependency. Used only for tests.

func DAGtoASCIIscheme

func DAGtoASCIIscheme(events dag.Events) (string, error)

DAGtoASCIIscheme builds ASCII-scheme of events for debug purpose.

func ForEachRandEvent

func ForEachRandEvent(
	nodes []idx.ValidatorID,
	eventCount int,
	parentCount int,
	r *rand.Rand,
	callback ForEachEvent,
) (
	events map[idx.ValidatorID]dag.Events,
)

ForEachRandEvent generates random events for test purpose. Result:

  • callbacks are called for each new event;
  • events maps node address to array of its events;

func ForEachRandFork

func ForEachRandFork(
	nodes []idx.ValidatorID,
	cheatersArr []idx.ValidatorID,
	eventCount int,
	parentCount int,
	forksCount int,
	r *rand.Rand,
	callback ForEachEvent,
) (
	events map[idx.ValidatorID]dag.Events,
)

ForEachRandFork generates random events with forks for test purpose. Result:

  • callbacks are called for each new event;
  • events maps node address to array of its events;

func GenNodes

func GenNodes(
	nodeCount int,
) (
	nodes []idx.ValidatorID,
)

GenNodes generates nodes. Result:

  • nodes is an array of node addresses;

func GenRandEvents

func GenRandEvents(
	nodes []idx.ValidatorID,
	eventCount int,
	parentCount int,
	r *rand.Rand,
) (
	events map[idx.ValidatorID]dag.Events,
)

GenRandEvents generates random events for test purpose. Result:

  • events maps node address to array of its events;

Types

type ForEachEvent

type ForEachEvent struct {
	Process func(e dag.Event, name string)
	Build   func(e dag.MutableEvent, name string) error
}

type TestEvent

type TestEvent struct {
	dag.MutableBaseEvent
	Name string
}

func (*TestEvent) AddParent

func (e *TestEvent) AddParent(id hash.Event)

func (*TestEvent) Bytes

func (e *TestEvent) Bytes() []byte

EventToBytes serializes events

type TestEventMarshaling

type TestEventMarshaling struct {
	Epoch idx.Epoch
	Seq   idx.Event

	Frame idx.Frame

	Creator idx.ValidatorID

	Parents hash.Events

	Lamport idx.Lamport

	ID   hash.Event
	Name string
}

type TestEvents

type TestEvents []*TestEvent

Events is a ordered slice of events.

func (TestEvents) ByParents

func (ee TestEvents) ByParents() (res TestEvents)

ByParents returns events topologically ordered by parent dependency. Used only for tests.

func (TestEvents) String

func (ee TestEvents) String() string

String returns human readable representation.

Jump to

Keyboard shortcuts

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