node

package
v1.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Overview

Package node does the initialization of all the required objects to either run as a synchronizer or as a coordinator.

The Node contains several goroutines that run in the background or that periodically perform tasks. One of this goroutines periodically calls the `Synchronizer.Sync` function, allowing the synchronization of one block at a time. After every call to `Synchronizer.Sync`, the Node sends a message to the Coordinator to notify it about the new synced block (and associated state) or reorg (and resetted state) in case one happens.

Other goroutines perform tasks such as: updating the token prices, update metrics stored in the historyDB, update recommended fee stored in the historyDB, run the http API server, run the debug http API server, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

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

APIServer is a server that only runs the API

func NewAPIServer

func NewAPIServer(mode Mode, cfg *config.APIServer, version string, ethClient *ethclient.Client, forgerAddress *ethCommon.Address) (*APIServer, error)

NewAPIServer creates a new APIServer

func (*APIServer) Start

func (s *APIServer) Start()

Start the APIServer

func (*APIServer) Stop

func (s *APIServer) Stop()

Stop the APIServer

type Mode

type Mode string

Mode sets the working mode of the node (synchronizer or coordinator)

const (
	// ModeCoordinator defines the mode of the HermezNode as Coordinator, which
	// means that the node is set to forge (which also will be synchronizing with
	// the L1 blockchain state)
	ModeCoordinator Mode = "coordinator"

	// ModeSynchronizer defines the mode of the HermezNode as Synchronizer, which
	// means that the node is set to only synchronize with the L1 blockchain state
	// and will not forge
	ModeSynchronizer Mode = "synchronizer"
)

type Node

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

Node is the Hermez Node

func NewNode

func NewNode(mode Mode, cfg *config.Node, version string) (*Node, error)

NewNode creates a Node

func (*Node) Start

func (n *Node) Start()

Start the node

func (*Node) StartDebugAPI

func (n *Node) StartDebugAPI()

StartDebugAPI starts the DebugAPI

func (*Node) StartNodeAPI

func (n *Node) StartNodeAPI()

StartNodeAPI starts the NodeAPI

func (*Node) StartSynchronizer

func (n *Node) StartSynchronizer()

StartSynchronizer starts the synchronizer

func (*Node) Stop

func (n *Node) Stop()

Stop the node

type NodeAPI

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

NodeAPI holds the node http API

func NewNodeAPI

func NewNodeAPI(
	version,
	addr string,
	coordinatorEndpoints, explorerEndpoints bool,
	server *gin.Engine,
	hdb *historydb.HistoryDB,
	l2db *l2db.L2DB,
	stateDB *statedb.StateDB,
	ethClient *ethclient.Client,
	forgerAddress *ethCommon.Address,
) (*NodeAPI, error)

NewNodeAPI creates a new NodeAPI (which internally calls api.NewAPI)

func (*NodeAPI) Run

func (a *NodeAPI) Run(ctx context.Context) error

Run starts the http server of the NodeAPI. To stop it, pass a context with cancellation.

Jump to

Keyboard shortcuts

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