Documentation ¶
Index ¶
- Constants
- type Opts
- type RouteStore
- type RouteStoreImpl
- func (s *RouteStoreImpl) AddDirectLink(ctx context.Context, currencyID byte, toAddr string) error
- func (s *RouteStoreImpl) AddRoute(ctx context.Context, currencyID byte, route []string, ttl time.Duration) error
- func (s *RouteStoreImpl) ListRoutesFrom(ctx context.Context, currencyID byte, toAddr string) (<-chan []string, <-chan error)
- func (s *RouteStoreImpl) ListRoutesTo(ctx context.Context, currencyID byte, toAddr string) (<-chan []string, <-chan error)
- func (s *RouteStoreImpl) MaxHop(ctx context.Context, currencyID byte) (uint64, error)
- func (s *RouteStoreImpl) RemoveDirectLink(ctx context.Context, currencyID byte, toAddr string) error
- func (s *RouteStoreImpl) RemoveRoute(ctx context.Context, currencyID byte, route []string) error
- func (s *RouteStoreImpl) Shutdown()
Constants ¶
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 (*RouteStoreImpl) AddDirectLink ¶
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 ¶
MaxHop is used to get the max hop supported for given currency.
@input - context, currency id.
@output - max hop, error.
func (*RouteStoreImpl) RemoveDirectLink ¶
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 ¶
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.