backend

package
v0.0.0-...-0001d10 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEkidenBackendNotImplemented = errors.New("ekiden backend is not implemented")
)
View Source
var NewBackendClient = ClientFactoryFunc(func(ctx context.Context, services *ClientServices, config *Config) (core.Client, error) {
	switch config.Provider {
	case BackendEthereum:
		return NewEthClient(ctx, &eth.ClientServices{
			Logger:    services.Logger,
			Callbacks: services.Callbacks,
		}, config.BackendConfig.(*EthereumConfig))
	case BackendEkiden:
		return nil, ErrEkidenBackendNotImplemented
	default:
		return nil, ErrUnknownBackend{Backend: config.Provider.String()}
	}
})
View Source
var NewRequestManagerWithDeps = RequestManagerFactoryFunc(func(ctx context.Context, deps *Deps) (*core.RequestManager, error) {
	return core.NewRequestManager(core.RequestManagerProperties{
		MQueue: deps.MQueue,
		Client: deps.Client,
		Logger: deps.Logger,
	}), nil
})

Functions

func NewEthClient

func NewEthClient(ctx context.Context, services *eth.ClientServices, config *EthereumConfig) (*eth.Client, error)

func NewEthClientWithDeps

func NewEthClientWithDeps(ctx context.Context, deps *eth.ClientDeps) (*eth.Client, error)

Types

type BackendConfig

type BackendConfig interface {
	log.Loggable
	config.Binder
	ID() BackendProvider
}

type BackendProvider

type BackendProvider string
const (
	BackendEthereum BackendProvider = "ethereum"
	BackendEkiden   BackendProvider = "ekiden"
)

func (BackendProvider) String

func (m BackendProvider) String() string

type ClientFactory

type ClientFactory interface {
	New(context.Context, *ClientServices, *Config) (core.Client, error)
}

type ClientFactoryFunc

type ClientFactoryFunc func(context.Context, *ClientServices, *Config) (core.Client, error)

func (ClientFactoryFunc) New

func (f ClientFactoryFunc) New(ctx context.Context, services *ClientServices, config *Config) (core.Client, error)

type ClientServices

type ClientServices struct {
	Logger    log.Logger
	Callbacks callback.Calls
}

type Config

type Config struct {
	Provider      BackendProvider
	BackendConfig BackendConfig
}

func (*Config) Bind

func (c *Config) Bind(v *viper.Viper, cmd *cobra.Command) error

func (*Config) Configure

func (c *Config) Configure(v *viper.Viper) error

func (*Config) Log

func (c *Config) Log(fields log.Fields)

type Deps

type Deps struct {
	Logger log.Logger
	MQueue mqueue.MQueue
	Client core.Client
}

type ErrUnknownBackend

type ErrUnknownBackend struct {
	Backend string
}

func (ErrUnknownBackend) Error

func (e ErrUnknownBackend) Error() string

type EthereumConfig

type EthereumConfig struct {
	URL          string
	WalletConfig WalletConfig
}

func (*EthereumConfig) Bind

func (c *EthereumConfig) Bind(v *viper.Viper, cmd *cobra.Command) error

func (*EthereumConfig) Configure

func (c *EthereumConfig) Configure(v *viper.Viper) error

func (*EthereumConfig) ID

func (*EthereumConfig) Log

func (c *EthereumConfig) Log(fields log.Fields)

type RequestManagerFactory

type RequestManagerFactory interface {
	New(ctx context.Context, deps *Deps) (*core.RequestManager, error)
}

type RequestManagerFactoryFunc

type RequestManagerFactoryFunc func(ctx context.Context, deps *Deps) (*core.RequestManager, error)

func (RequestManagerFactoryFunc) New

type WalletConfig

type WalletConfig struct {
	// PrivateKeys for the wallet
	PrivateKeys []string
}

WalletConfig holds the configuration of a single wallet

func (*WalletConfig) Bind

func (c *WalletConfig) Bind(v *viper.Viper, cmd *cobra.Command) error

func (*WalletConfig) Configure

func (c *WalletConfig) Configure(v *viper.Viper) error

func (*WalletConfig) Log

func (c *WalletConfig) Log(fields log.Fields)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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