services

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithEncRPCConnection

func WithEncRPCConnection[R any](ctx context.Context, rpc *BackendRPC, acct *wecommon.GWAccount, execute func(*tenrpc.EncRPCClient) (*R, error)) (*R, error)

func WithPlainRPCConnection

func WithPlainRPCConnection[R any](ctx context.Context, b *BackendRPC, execute func(client *rpc.Client) (*R, error)) (*R, error)

Types

type BackendRPC

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

func NewBackendRPC

func NewBackendRPC(hostAddrHTTP string, hostAddrWS string, logger gethlog.Logger) *BackendRPC

func (*BackendRPC) ConnectHttp

func (rpc *BackendRPC) ConnectHttp(ctx context.Context, account *wecommon.GWAccount) (*tenrpc.EncRPCClient, error)

func (*BackendRPC) ConnectWS

func (rpc *BackendRPC) ConnectWS(ctx context.Context, account *wecommon.GWAccount) (*tenrpc.EncRPCClient, error)

func (*BackendRPC) PlainConnectWs

func (rpc *BackendRPC) PlainConnectWs(ctx context.Context) (*gethrpc.Client, error)

func (*BackendRPC) ReturnConn

func (rpc *BackendRPC) ReturnConn(conn tenrpc.Client) error

func (*BackendRPC) ReturnConnWS

func (rpc *BackendRPC) ReturnConnWS(conn tenrpc.Client) error

func (*BackendRPC) Stop

func (rpc *BackendRPC) Stop()

type NewHeadNotifier

type NewHeadNotifier interface {
	// contains filtered or unexported methods
}

type Services

type Services struct {
	HostAddrHTTP string // The HTTP address on which the TEN host can be reached
	HostAddrWS   string // The WS address on which the TEN host can be reached
	Storage      storage.UserStorage

	RPCResponsesCache cache.Cache
	BackendRPC        *BackendRPC
	RateLimiter       *ratelimiter.RateLimiter
	Config            *common.Config
	NewHeadsService   *subscriptioncommon.NewHeadsService
	// contains filtered or unexported fields
}

Services handles the various business logic for the api endpoints

func NewServices

func NewServices(hostAddrHTTP string, hostAddrWS string, storage storage.UserStorage, stopControl *stopcontrol.StopControl, version string, logger gethlog.Logger, config *common.Config) *Services

func (*Services) AddAddressToUser

func (w *Services) AddAddressToUser(userID []byte, address string, signature []byte, signatureType viewingkey.SignatureType) error

AddAddressToUser checks if a message is in correct format and if signature is valid. If all checks pass we save address and signature against userID

func (*Services) GenerateAndStoreNewUser

func (w *Services) GenerateAndStoreNewUser() ([]byte, error)

GenerateAndStoreNewUser generates new key-pair and userID, stores it in the database and returns hex encoded userID and error

func (*Services) GenerateUserMessageToSign

func (w *Services) GenerateUserMessageToSign(encryptionToken []byte, formatsSlice []string) (string, error)

func (*Services) GetTenNetworkConfig

func (w *Services) GetTenNetworkConfig() (tencommon.TenNetworkInfo, error)

func (*Services) GetTenNodeHealthStatus

func (w *Services) GetTenNodeHealthStatus() (bool, error)

func (*Services) IsStopping

func (w *Services) IsStopping() bool

IsStopping returns whether the WE is stopping

func (*Services) Logger

func (w *Services) Logger() gethlog.Logger

Logger returns the WE set logger

func (*Services) Stop

func (w *Services) Stop()

func (*Services) UserExists

func (w *Services) UserExists(userID []byte) bool

func (*Services) UserHasAccount

func (w *Services) UserHasAccount(userID []byte, address string) (bool, error)

UserHasAccount checks if provided account exist in the database for given userID

func (*Services) Version

func (w *Services) Version() string

Jump to

Keyboard shortcuts

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