state

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package state defines the states of the node state machine.

Index

Constants

View Source
const WGLIMIT = 20

WGLIMIT is the maximum number of goroutines that can be launched through state.GoFunc

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager wraps a State with get and set methods. It is also used to limit the number of goroutines launched by the node, and to wait for all of them to complete.

func (*Manager) GetState

func (b *Manager) GetState() State

GetState returns the current state.

func (*Manager) GoFunc

func (b *Manager) GoFunc(f func())

GoFunc launches a goroutine for a given function, if there are currently less than WGLIMIT running. It increments the waitgroup.

func (*Manager) SetState

func (b *Manager) SetState(s State)

SetState sets the state.

func (*Manager) WaitRoutines

func (b *Manager) WaitRoutines()

WaitRoutines waits for all the goroutines in the waitgroup.

type State

type State uint32

State captures the state of a Babble node: Babbling, CatchingUp, Joining, Leaving, Suspended, or Shutdown

const (
	// Babbling is the state in which a node gossips regularly with other nodes
	// as part of the hashgraph consensus algorithm, and responds to other
	// requests.
	Babbling State = iota

	// CatchingUp is the state in which a node attempts to fast-forward to a
	// future point in the hashgraph as part of the FastSync protocol.
	CatchingUp

	// Joining is the state in which a node attempts to join a Babble group by
	// submitting a join request.
	Joining

	// Leaving is the state in which a node attempts to politely leave a Babble
	// group by submitting a leave request.
	Leaving

	// Shutdown is the state in which a node stops responding to external events
	// and closes its transport.
	Shutdown

	// Suspended is the state in which a node passively participates in the
	// gossip protocol but does not process any new events or transactions.
	Suspended
)

func (State) String

func (s State) String() string

String returns the string representation of a State

Jump to

Keyboard shortcuts

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