server

package
v0.0.0-...-15eb78e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NetFilename is the name of the net file in the kmd data dir
	NetFilename = "kmd.net"
	// PIDFilename is the name of the PID file in the kmd data dir
	PIDFilename = "kmd.pid"
	// LockFilename is the name of the lock file in the kmd data dir
	LockFilename = "kmd.lock"
	// DefaultKMDPort is the port that kmd will first try to start on if none is specified
	DefaultKMDPort = 7833
	// DefaultKMDHost is the host that kmd will first try to start on if none is specified
	DefaultKMDHost = "127.0.0.1"
)

Variables

View Source
var ErrAlreadyRunning = fmt.Errorf("failed to lock kmd.lock; is an instance of kmd already running in this data directory?")

ErrAlreadyRunning is returned if we failed to start kmd because we couldn't acquire its file lock. We export this so that the kmd cli can return a different exit code for this situation

Functions

func ValidateConfig

func ValidateConfig(cfg WalletServerConfig) error

ValidateConfig returns an error if and only if the passed WalletServerConfig is invalid.

Types

type WalletServer

type WalletServer struct {
	WalletServerConfig
	// contains filtered or unexported fields
}

WalletServer deals with serving API requests

func MakeWalletServer

func MakeWalletServer(config WalletServerConfig) (*WalletServer, error)

MakeWalletServer takes a WalletServerConfig, and returns a validated, configured WalletServer.

func (*WalletServer) Start

func (ws *WalletServer) Start(kill chan os.Signal) (died chan error, sock string, err error)

Start begins serving kmd API requests from the configured WalletServer. It returns an error if it was unable to start the server. It reads from the `kill` channel in order to shut down the server gracefully, and returns a `died` channel that will be written after the server exits.

type WalletServerConfig

type WalletServerConfig struct {
	APIToken       string
	DataDir        string
	Address        string
	AllowedOrigins []string
	SessionManager *session.Manager
	Log            logging.Logger
	Timeout        *time.Duration
}

WalletServerConfig is the configuration passed to MakeWalletServer

Jump to

Keyboard shortcuts

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