node

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 71 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeStopped = errors.New("node not started")
	ErrNodeRunning = errors.New("node already running")
)

Functions

func CheckOverlayWithStore added in v1.1.0

func CheckOverlayWithStore(overlay boson.Address, storer storage.StateStorer) error

CheckOverlayWithStore checks the overlay is the same as stored in the statestore

func CheckTimeouts added in v1.2.1

func CheckTimeouts(timeouts *rpc.HTTPTimeouts, log logging.Logger)

CheckTimeouts ensures that timeout values are meaningful

func InitChain

func InitChain(
	ctx context.Context,
	logger logging.Logger,
	endpoint string,
	oracleContractAddress string,
	stateStore storage.StateStorer,
	signer crypto.Signer,
	trafficEnable bool,
	trafficContractAddr string,
	p2pService *libp2p.Service,
	subPub subscribe.SubPub,
) (chain.Resolver, settlement.Interface, traffic.ApiInterface, chain.Common, error)

InitChain will initialize the Ethereum backend at the given endpoint and set up the Transaction Service to interact with it using the provided signer.

func InitStateStore added in v1.1.0

func InitStateStore(log logging.Logger, dataDir string) (ret storage.StateStorer, err error)

InitStateStore will initialize the stateStore with the given path to the data directory. When given an empty directory path, the function will instead initialize an in-memory state store that will not be persisted.

func InitTraffic added in v1.2.1

func InitTraffic(store storage.StateStorer, address common.Address, trafficChainService chain.Traffic,
	transactionService chain.Transaction, logger logging.Logger, p2pService *libp2p.Service, signer crypto.Signer, chainID int64, trafficContractAddr string, subPub subscribe.SubPub) (*traffic.Service, error)

func NewHTTPHandlerStack added in v1.2.1

func NewHTTPHandlerStack(srv http.Handler, cors []string, vhosts []string) http.Handler

NewHTTPHandlerStack returns wrapped http-related handlers

Types

type Config added in v1.2.1

type Config struct {
	EnableApiTLS     bool
	TlsCrtFile       string
	TlsKeyFile       string
	DebugAPIAddr     string
	APIAddr          string
	DataDir          string
	IPCPath          string
	HTTPAddr         string
	HTTPCors         []string
	HTTPVirtualHosts []string
	HTTPModules      []string
	HTTPTimeouts     rpc.HTTPTimeouts
	HTTPPathPrefix   string
	WSAddr           string
	WSPathPrefix     string
	WSOrigins        []string
	WSModules        []string
}

type Favor

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

func NewNode

func NewNode(nodeMode address.Model, addr string, bosonAddress boson.Address, publicKey ecdsa.PublicKey, signer crypto.Signer, networkID uint64, logger logging.Logger, libp2pPrivateKey crypto2.PrivKey, o Options) (b *Favor, err error)

func (*Favor) Shutdown

func (b *Favor) Shutdown(ctx context.Context) error

type Node added in v1.2.1

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

Node is a container on which services can be registered.

func NewRPC added in v1.2.1

func NewRPC(log logging.Logger, conf Config) (*Node, error)

func (*Node) Attach added in v1.2.1

func (n *Node) Attach() (*rpc.Client, error)

Attach creates an RPC client attached to an in-process API handler.

func (*Node) Close added in v1.2.1

func (n *Node) Close() error

Close stops the Node and releases resources acquired in Node constructor New.

func (*Node) Config added in v1.2.1

func (n *Node) Config() Config

Config returns the configuration of node.

func (*Node) HTTPEndpoint added in v1.2.1

func (n *Node) HTTPEndpoint() string

HTTPEndpoint returns the URL of the HTTP server. Note that this URL does not contain the JSON-RPC path prefix set by HTTPPathPrefix.

func (*Node) IPCEndpoint added in v1.2.1

func (n *Node) IPCEndpoint() string

IPCEndpoint retrieves the current IPC endpoint used by the protocol stack.

func (*Node) RPCHandler added in v1.2.1

func (n *Node) RPCHandler() (*rpc.Server, error)

RPCHandler returns the in-process RPC request handler.

func (*Node) RegisterAPIs added in v1.2.1

func (n *Node) RegisterAPIs(apis []rpc.API)

RegisterAPIs registers the APIs a service provides on the node.

func (*Node) RegisterHandler added in v1.2.1

func (n *Node) RegisterHandler(name, path string, handler http.Handler)

RegisterHandler mounts a handler on the given path on the canonical HTTP server.

The name of the handler is shown in a log message when the HTTP server starts and should be a descriptive term for the service provided by the handler.

func (*Node) Start added in v1.2.1

func (n *Node) Start() error

Start RPC services

func (*Node) WSEndpoint added in v1.2.1

func (n *Node) WSEndpoint() string

WSEndpoint returns the current JSON-RPC over WebSocket endpoint.

func (*Node) Wait added in v1.2.1

func (n *Node) Wait()

Wait blocks until the node is closed.

type Options

type Options struct {
	DataDir                string
	CacheCapacity          uint64
	DBDriver               string
	DBPath                 string
	HTTPAddr               string
	WSAddr                 string
	APIAddr                string
	DebugAPIAddr           string
	ApiBufferSizeMul       int
	NATAddr                string
	EnableWS               bool
	EnableQUIC             bool
	WelcomeMessage         string
	Bootnodes              []string
	ChainEndpoint          string
	OracleContractAddress  string
	CORSAllowedOrigins     []string
	Logger                 logging.Logger
	Standalone             bool
	IsDev                  bool
	TracingEnabled         bool
	TracingEndpoint        string
	TracingServiceName     string
	ResolverConnectionCfgs []multiresolver.ConnectionConfig
	GatewayMode            bool
	TrafficEnable          bool
	TrafficContractAddr    string
	KadBinMaxPeers         int
	LightNodeMaxPeers      int
	AllowPrivateCIDRs      bool
	Restricted             bool
	TokenEncryptionKey     string
	AdminPasswordHash      string
	RouteAlpha             int32
	Groups                 []model.ConfigNodeGroup
	EnableApiTLS           bool
	TlsCrtFile             string
	TlsKeyFile             string
	ProxyEnable            bool
	ProxyAddr              string
	ProxyNATAddr           string
	ProxyGroup             string
	TunEnable              bool
	TunCidr4               string
	TunCidr6               string
	TunMTU                 int
	TunServiceIPv4         string
	TunServiceIPv6         string
	VpnGroup               string
	VpnListen              string
}

Jump to

Keyboard shortcuts

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