devnet

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package devnet provides functionality to start and manage a development network (devnet) consisting of multiple nodes. It offers utilities for configuring and starting nodes with various consensus mechanisms, such as BootstrapSequencer or Sequencer. The package handles the creation of Avail accounts, configuration of node settings, and starting the associated servers. It also provides functions to interact with the devnet, such as obtaining the JSON-RPC URL or stopping all the nodes.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidNodeType = errors.New("invalid node type")

ErrInvalidNodeType is returned when an invalid node type is provided.

Functions

This section is empty.

Types

type Context

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

Context represents the devnet context with information about the running nodes.

func StartNodes

func StartNodes(logger hclog.Logger, bindAddr netip.Addr, availAddr, accountsPath string, nodeTypes ...consensus.MechanismType) (*Context, error)

StartNodes starts the devnet nodes based on the provided parameters. It creates the Avail accounts, configures and starts the nodes, and returns the devnet context.

func (*Context) FirstRPCAddrForNodeType

func (sc *Context) FirstRPCAddrForNodeType(nodeType consensus.MechanismType) (*net.TCPAddr, error)

FirstRPCAddrForNodeType looks up and returns the JSON-RPC URL of the node for the specified node type.

func (*Context) GethClient

func (sc *Context) GethClient(nodeType consensus.MechanismType) (*ethclient.Client, error)

GethClient returns an Ethereum client for the specified node type. It connects to the JSON-RPC URL of the first available node of the specified type.

func (*Context) Output

func (sc *Context) Output(w io.Writer)

Output prints the details of all the devnet nodes to the provided writer.

func (*Context) StopAll

func (sc *Context) StopAll()

StopAll stops all the running devnet nodes.

type PortAllocator

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

PortAllocator provides functionality to allocate and release ports for node communication.

func NewPortAllocator

func NewPortAllocator(bindAddr netip.Addr) *PortAllocator

NewPortAllocator creates a new PortAllocator with the provided bind address.

func (*PortAllocator) Allocate

func (pa *PortAllocator) Allocate() (netip.AddrPort, error)

Allocate allocates a new port from the PortAllocator's bind address. It returns the allocated port as a netip.AddrPort.

func (*PortAllocator) Release

func (pa *PortAllocator) Release() error

Release releases all the ports allocated by the PortAllocator. It returns the last error encountered during port release, if any.

Jump to

Keyboard shortcuts

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