server

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: 52 Imported by: 0

Documentation

Overview

Server package for the blockchain client.

Index

Constants

View Source
const (
	// DefaultGRPCPort is the default port for the GRPC server
	DefaultGRPCPort int = 9632

	// DefaultJSONRPCPort is the default port for the JSON-RPC server
	DefaultJSONRPCPort int = 8545
)

Variables

This section is empty.

Functions

func ExtractBlockTime

func ExtractBlockTime(engineConfig map[string]interface{}) (common.Duration, error)

ExtractBlockTime attempts to extract a blockTime parameter from a given consensus engine configuration map. It returns a Duration type. If blockTime is missing or invalid, it returns an appropriate error.

Types

type Config

type Config struct {
	// Chain configuration
	Chain *chain.Chain

	// JSON-RPC server configuration
	JSONRPC *JSONRPC

	// TCP address for the GRPC server
	GRPCAddr *net.TCPAddr

	// TCP address for the LibP2P server
	LibP2PAddr *net.TCPAddr

	// Various blockchain-related parameters
	PriceLimit         uint64
	MaxAccountEnqueued uint64
	MaxSlots           uint64
	BlockTime          uint64

	// Telemetry configuration for metric services
	Telemetry *Telemetry

	// Network configuration
	Network *network.Config

	// Data directory for the server
	DataDir string

	// Restore file path, if any
	RestoreFile *string

	// Flag to enable or disable sealing
	Seal bool

	// Secrets manager configuration
	SecretsManager *secrets.SecretsManagerConfig

	// Log level for the server
	LogLevel hclog.Level

	// Flag to enable or disable JSON log format
	JSONLogFormat bool

	// Path for the log file
	LogFilePath string

	// Flag to enable or disable relayer mode
	Relayer bool

	// Number of block confirmations required
	NumBlockConfirmations uint64
}

Config is the main configuration struct for the server. It holds various sub-configurations related to different components of the server.

type Entry

type Entry struct {
	Enabled bool
	Config  map[string]interface{}
}

Entry represents a configuration entry for a consensus protocol. It includes an Enabled field that indicates whether the entry is in use, and a Config field that holds the entry's configuration data. The Config field is a map of string keys to values of any type.

type GenesisFactoryHook

type GenesisFactoryHook func(config *chain.Chain, engineName string) func(*state.Transition) error

GenesisFactoryHook is a type definition for a function that takes a chain configuration and an engine name, and returns a function that accepts a state transition object and returns an error. It is typically used to modify the behavior of the blockchain's genesis block production based on specific engine.

type JSONRPC

type JSONRPC struct {
	// TCP address for the JSON-RPC server
	JSONRPCAddr *net.TCPAddr

	// Allowed origins for CORS
	AccessControlAllowOrigin []string

	// Limit for the number of items in a batch request
	BatchLengthLimit uint64

	// Limit for the number of blocks in a range request
	BlockRangeLimit uint64
}

JSONRPC holds the configuration details for the JSON-RPC server.

type Server

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

Server struct defines the central manager of the blockchain client.

func NewServer

func NewServer(config *server.Config, consensusCfg avail_consensus.Config) (*Server, error)

NewServer creates a new minimal server, using the passed in configuration.

func (*Server) Chain

func (s *Server) Chain() *chain.Chain

Chain retrieves the server's Chain instance. Chain represents the blockchain associated with this server.

func (*Server) Close

func (s *Server) Close()

Close shuts down all components of the server, including the blockchain, networking layer, consensus layer, and state storage. If a Prometheus server is running, it is also shut down. Errors during shutdown are logged but not returned, as the method always succeeds.

func (*Server) JoinPeer

func (s *Server) JoinPeer(rawPeerMultiaddr string) error

JoinPeer attempts to add a new peer to the server's network. The peer is identified by the provided multiaddress. If an error occurs while joining the peer, it is returned immediately.

type Telemetry

type Telemetry struct {
	// TCP address for the Prometheus server
	PrometheusAddr *net.TCPAddr
}

Telemetry holds the configuration details for metric services.

Jump to

Keyboard shortcuts

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