routestore

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteKeySeperator = "-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Opts

type Opts struct {
	// The datastore path of the route store.
	Path string

	// Cleaning frequency.
	CleanFreq time.Duration

	// Cleaning timeout.
	CleanTimeout time.Duration

	// The max hop for FIL.
	MaxHopFIL uint64
}

Opts is the options for route store.

type RouteStore

type RouteStore interface {
	// MaxHop is used to get the max hop supported for given currency.
	//
	// @input - currency id.
	//
	// @output - max hop, error.
	MaxHop(ctx context.Context, currencyID byte) (uint64, error)

	// AddDirectLink is used to add direct link from this node.
	//
	// @input - context, currency id, recipient address.
	//
	// @output - error.
	AddDirectLink(ctx context.Context, currencyID byte, toAddr string) error

	// RemoveDirectLink is used to remove direct link from this node.
	//
	// @input - context, currency id, recipient address.
	//
	// @output - error.
	RemoveDirectLink(ctx context.Context, currencyID byte, toAddr string) error

	// AddRoute is used to add a route.
	//
	// @input - context, currency id, route, time to live.
	//
	// @output - error.
	AddRoute(ctx context.Context, currencyID byte, route []string, ttl time.Duration) error

	// RemoveRoute is used to remove a route.
	//
	// @input - context, currency id, route.
	//
	// @output - error.
	RemoveRoute(ctx context.Context, currencyID byte, route []string) error

	// ListRoutesTo is used to list all routes that has given destination.
	//
	// @input - context, currency id.
	//
	// @output - route chan out, error chan out.
	ListRoutesTo(ctx context.Context, currencyID byte, toAddr string) (<-chan []string, <-chan error)

	// ListRoutesFrom is used to list all routes that has given source.
	//
	// @input - context, currency id.
	//
	// @output - route chan out, error chan out.
	ListRoutesFrom(ctx context.Context, currencyID byte, toAddr string) (<-chan []string, <-chan error)
}

RouteStore is the interface for a route store that storing all routes.

type RouteStoreImpl

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

RouteStoreImpl is the implementation of the RouteStore interface.

func NewRouteStoreImpl

func NewRouteStoreImpl(ctx context.Context, signer crypto.Signer, opts Opts) (*RouteStoreImpl, error)

NewRouteStoreImpl creates a new RouteStoreImpl.

@input - context, signer, options.

@output - route store, error.

func (s *RouteStoreImpl) AddDirectLink(ctx context.Context, currencyID byte, toAddr string) error

AddDirectLink is used to add direct link from this node.

@input - context, recipient address.

@output - error.

func (*RouteStoreImpl) AddRoute

func (s *RouteStoreImpl) AddRoute(ctx context.Context, currencyID byte, route []string, ttl time.Duration) error

AddRoute is used to add a route.

@input - context, currency id, route, time to live.

@output - error.

func (*RouteStoreImpl) ListRoutesFrom

func (s *RouteStoreImpl) ListRoutesFrom(ctx context.Context, currencyID byte, toAddr string) (<-chan []string, <-chan error)

ListRoutesFrom is used to list all routes that has given source.

@input - context, currency id.

@output - route chan out, error chan out.

func (*RouteStoreImpl) ListRoutesTo

func (s *RouteStoreImpl) ListRoutesTo(ctx context.Context, currencyID byte, toAddr string) (<-chan []string, <-chan error)

ListRoutesTo is used to list all routes that has given destination.

@input - context, currency id.

@output - route chan out, error chan out.

func (*RouteStoreImpl) MaxHop

func (s *RouteStoreImpl) MaxHop(ctx context.Context, currencyID byte) (uint64, error)

MaxHop is used to get the max hop supported for given currency.

@input - context, currency id.

@output - max hop, error.

func (s *RouteStoreImpl) RemoveDirectLink(ctx context.Context, currencyID byte, toAddr string) error

RemoveDirectLink is used to remove direct link from this node.

@input - context, currency id, recipient address.

@output - error.

func (*RouteStoreImpl) RemoveRoute

func (s *RouteStoreImpl) RemoveRoute(ctx context.Context, currencyID byte, route []string) error

RemoveRoute is used to remove a route.

@input - context, currency id, route.

@output - error.

func (*RouteStoreImpl) Shutdown

func (s *RouteStoreImpl) Shutdown()

Shutdown safely shuts down the component.

Jump to

Keyboard shortcuts

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