relaylib

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotStarted           = errors.New("controller not started")
	ErrAlreadyStarted       = errors.New("controller already started")
	ErrContractNotFound     = errors.New("relay contract not found")
	ErrContractNotAvailable = errors.New("relay contract not available")
	ErrDisenroll            = errors.New("disenrollment patially failed, couldn't disenroll the following contracts")
)
View Source
var (
	ErrFetchDirUrl = errors.New("could not get directory URL")
	ErrRequest     = errors.New("could not create enrollment request")
	ErrReloadCfg   = errors.New("forbidden change, could not apply new relay config")
)

Functions

func Get

func Get(cl *client.Client, url string) (*json.RawMessage, error)

func NewRelayStatus added in v0.5.1

func NewRelayStatus(cl *client.Client, scurl texturl.URL, cfg *relayentryext.T) (rs relayStatus, err error)

func SubmitST

func SubmitST(cl *client.Client, url string, st *sharetoken.T) error

func SubmitSTFromFile

func SubmitSTFromFile(cl *client.Client, url, shares string) error

func Withdraw

func Withdraw(cl *client.Client, url string, destination string, amount int64) (*json.RawMessage, error)

Types

type Controller added in v0.5.1

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

Controller is the serverlib relay handler Interaction with the relays is always done through the controller

func NewController added in v0.5.1

func NewController(cl *client.Client, callback chan *status.T) *Controller

Create new controller instance

func (*Controller) Contracts added in v0.5.1

func (c *Controller) Contracts() (l []string)

Returns current contractIds

func (*Controller) Disable added in v0.5.1

func (c *Controller) Disable(contractId string) error

Disenroll relay by contractId

func (*Controller) Disenroll added in v0.5.1

func (c *Controller) Disenroll(contractId string) error

Disenroll relay by contractId

func (*Controller) DisenrollAll added in v0.5.1

func (c *Controller) DisenrollAll() (err error)

Disenroll all the relays

func (*Controller) Enroll added in v0.5.1

func (c *Controller) Enroll(contractId string) error

Enroll relay by contractId

func (*Controller) EnrollAll added in v0.5.1

func (c *Controller) EnrollAll() (err error)

Enroll all the relays

func (*Controller) Load added in v0.5.1

func (c *Controller) Load(scfg *relaycfg.C) (err error)

Load current relays configuration

func (*Controller) NetCap added in v0.6.0

func (c *Controller) NetCap() (m map[string]uint64)

Returns current relays Netcaps, by contractId

func (*Controller) NewConn added in v0.5.1

func (c *Controller) NewConn(contractId string) (ctx context.Context, err error)

Returns if a new connection should be accepted Relays accept new connections meanwhile they're enrolled

func (*Controller) Reload added in v0.5.1

func (c *Controller) Reload(scfg *relaycfg.C) (err error)

Reload current relays configuration

func (*Controller) SCS added in v0.5.1

func (c *Controller) SCS() (m map[string]string)

Returns current relays SC, by contractId

func (*Controller) Start added in v0.5.1

func (c *Controller) Start() error

Controller starter Enrolls relays and starts heartbeat goroutine

func (*Controller) StartWithList added in v0.5.1

func (c *Controller) StartWithList(contractIds ...string) error

Controller starter, with custom list Enrolls relays and starts heartbeat goroutine

func (*Controller) Started added in v0.5.1

func (c *Controller) Started() bool

Returns current Controller status

func (*Controller) Status added in v0.5.1

func (c *Controller) Status() (m map[string]RelayStatus)

Returns current relays status, by contractId

func (*Controller) Stop added in v0.5.1

func (c *Controller) Stop() error

Controller finisher

type RelayFlags added in v0.5.1

type RelayFlags struct {
	Enrolled      bool
	NetCapReached bool
}

type RelayStatus added in v0.5.1

type RelayStatus struct {
	Addr  *texturl.URL
	Role  string
	Flags RelayFlags
}

RelayStatus minified version of relayStatus

Jump to

Keyboard shortcuts

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