paychmon

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opts

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

	// The check frequency of payment channels.
	CheckFreq time.Duration
}

Opts is the options for paych monitor.

type PaychMonitor

type PaychMonitor interface {
	// Track starts tracking a payment channel.
	//
	// @input - context, if it is outbound channel, currency id, channel address, settlement time.
	//
	// @output - error.
	Track(ctx context.Context, outbound bool, currencyID byte, chAddr string, settlement time.Time) error

	// Check checks the current settlement of a payment channel.
	//
	// @input - context, if it is outbound channel, currency id, channel address.
	//
	// @output - last update time, settlement time, error.
	Check(ctx context.Context, outbound bool, currencyID byte, chAddr string) (time.Time, time.Time, error)

	// Renew renews a payment channel.
	//
	// @input - context, if it is outbound channel, currency id, channel address, new settlement time.
	//
	// @output - error.
	Renew(ctx context.Context, outbound bool, currencyID byte, chAddr string, newSettlement time.Time) error

	// Retire retires a payment channel.
	//
	// @input - context, if it is outbound channel, currency id, channel address.
	//
	// @output - error.
	Retire(ctx context.Context, outbound bool, currencyID byte, chAddr string) error
}

PaychMonitor is used to track and monitor all payment channels. Once a payment channel is non-active, it will send request to payment manager for retirement.

type PaychMonitorImpl

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

PaychMonitorImpl implements the PaychMonitor interface.

func NewPaychMonitorImpl

func NewPaychMonitorImpl(ctx context.Context, pam paymgr.PaymentManager, transactor trans.Transactor, opts Opts) (*PaychMonitorImpl, error)

NewPaychMonitorImpl creates a new PaychMonitorImpl.

@input - context, payment manager, transactor, options.

@output - paych monitor, error.

func (*PaychMonitorImpl) Check

func (m *PaychMonitorImpl) Check(ctx context.Context, outbound bool, currencyID byte, chAddr string) (time.Time, time.Time, error)

Check checks the current settlement of a payment channel.

@input - context, if it is outbound channel, currency id, channel address.

@output - last update time, settlement time, error.

func (*PaychMonitorImpl) Renew

func (m *PaychMonitorImpl) Renew(ctx context.Context, outbound bool, currencyID byte, chAddr string, newSettlement time.Time) error

Renew renews a payment channel.

@input - context, if it is outbound channel, currency id, channel address, new settlement time.

@output - error.

func (*PaychMonitorImpl) Retire

func (m *PaychMonitorImpl) Retire(ctx context.Context, outbound bool, currencyID byte, chAddr string) error

Retire retires a payment channel.

@input - context, if it is outbound channel, currency id, channel address.

@output - error.

func (*PaychMonitorImpl) Shutdown

func (m *PaychMonitorImpl) Shutdown()

Shutdown safely shuts down the component.

func (*PaychMonitorImpl) Track

func (m *PaychMonitorImpl) Track(ctx context.Context, outbound bool, currencyID byte, chAddr string, settlement time.Time) error

Track starts tracking a payment channel.

@input - context, if it is outbound channel, currency id, peer address, channel address, settlement time.

@output - error.

Jump to

Keyboard shortcuts

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