sdkgo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

sdk-go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultListenAddr = func(cfg *Config) error {
	addrs := "0.0.0.0"
	return cfg.Apply(ListenAddrStrings(addrs))
}

DefaultListenAddr configures client to use default listen address.

View Source
var DefaultListenPort = func(cfg *Config) error {
	port := 15000
	return cfg.Apply(ListenPort(port))
}

DefaultListenPort configures client to use default listen port.

View Source
var DefaultRpcAddrs = func(cfg *Config) error {
	rpcAddrs := []string{
		"wss://testnet-rpc0.cess.cloud/ws/",
		"wss://testnet-rpc1.cess.cloud/ws/",
	}
	return cfg.Apply(ConnectRpcAddrs(rpcAddrs))
}

DefaultRpcAddrs configures client to use default RPC address.

View Source
var DefaultWorkspace = func(cfg *Config) error {
	workspace, err := os.Getwd()
	if err != nil {
		return err
	}
	return cfg.Apply(Workspace(workspace))
}

DefaultWorkspace configures client to use default workspace.

Functions

func New

func New(name string, opts ...Option) (client.Client, error)

New constructs a new client with the given options, falling back on reasonable defaults. The defaults are:

- If no transport and listen addresses are provided, the node listens to the default addresses "/ip4/0.0.0.0/tcp/15000";

- If no Rpc address is provided, the client uses the default address "wss://testnet-rpc0.cess.cloud/ws/"" or "wss://testnet-rpc1.cess.cloud/ws/";

- If no working directory is provided, the client uses the current directory as the working directory;

func NewWithoutDefaults

func NewWithoutDefaults(name string, opts ...Option) (client.Client, error)

NewWithoutDefaults constructs a new client with the given options but *without* falling back on reasonable defaults.

Warning: This function should not be considered a stable interface. We may choose to add required services at any time and, by using this function, you opt-out of any defaults we may provide.

Types

type Config

type Config = config.Config

Config describes a set of settings for a client.

type Option

type Option = config.Option

Option is a client config option that can be given to the client constructor

var FallbackDefaults Option = func(cfg *Config) error {
	for _, def := range defaults {
		if !def.fallback(cfg) {
			continue
		}
		if err := cfg.Apply(def.opt); err != nil {
			return err
		}
	}
	return nil
}

FallbackDefaults applies default options to the libp2p node if and only if no other relevant options have been applied. will be appended to the options passed into New.

func ConnectRpcAddrs

func ConnectRpcAddrs(s []string) Option

ConnectRpcAddrs configures client to connect to the given RPC addresses.

func ListenAddrStrings

func ListenAddrStrings(s string) Option

ListenAddrStrings configures client to listen on the given (unparsed) addresses.

func ListenPort

func ListenPort(port int) Option

ListenPort configures client to listen on the given (unparsed) port.

func Mnemonic

func Mnemonic(mnemonic string) Option

Workspace configures client to use the given workspace.

func Workspace

func Workspace(workspace string) Option

Workspace configures client to use the given workspace.

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

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