Documentation ¶
Index ¶
- Constants
- type Opts
- type SettlementManager
- type SettlementManagerImpl
- func (s *SettlementManagerImpl) GetDefaultPolicy(ctx context.Context, currencyID byte) (time.Duration, error)
- func (s *SettlementManagerImpl) GetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) (time.Duration, error)
- func (s *SettlementManagerImpl) ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)
- func (s *SettlementManagerImpl) ListSenders(ctx context.Context, currencyID byte) (<-chan string, <-chan error)
- func (s *SettlementManagerImpl) RemoveDefaultPolicy(ctx context.Context, currencyID byte) error
- func (s *SettlementManagerImpl) RemoveSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) error
- func (s *SettlementManagerImpl) SetDefaultPolicy(ctx context.Context, currencyID byte, duration time.Duration) error
- func (s *SettlementManagerImpl) SetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string, duration time.Duration) error
- func (s *SettlementManagerImpl) Shutdown()
Constants ¶
const (
DefaultPolicyID = "default"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opts ¶
type Opts struct { // The datastore path of the settlement manager. Path string }
Opts is the options for settlement manager.
type SettlementManager ¶
type SettlementManager interface { // SetDefaultPolicy sets the default settlement policy. // // @input - context, currency id, settlement duration. // // @output - error. SetDefaultPolicy(ctx context.Context, currencyID byte, duration time.Duration) error // GetDefaultPolicy gets the default settlement policy. // // @input - context, currency id. // // @output - settlement duration, error. GetDefaultPolicy(ctx context.Context, currencyID byte) (time.Duration, error) // RemoveDefaultPolicy removes the default settlement policy. // // @input - context, currency id. // // @output - error. RemoveDefaultPolicy(ctx context.Context, currencyID byte) error // SetSenderPolicy sets a settlement policy for a given sender. // // @input - context, currency id, payment channel sender, settlement duration. // // @output - error. SetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string, duration time.Duration) error // GetSenderPolicy gets the policy for a given currency id and sender pair. // // @input - context, currency id, payment channel sender. // // @output - settlement duration, error. GetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) (time.Duration, error) // RemoveSenderPolicy removes a policy. // // @input - context, currency id, payment channel sender. // // @output - error. RemoveSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) error // ListCurrencyIDs lists all currency ids. // // @input - context. // // @output - currency id chan out, error chan out. ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error) // ListSenders lists all senders with a policy set. // // @input - context, currency id. // // @output - sender chan out (could be default policy id or sender addr), error chan out. ListSenders(ctx context.Context, currencyID byte) (<-chan string, <-chan error) }
SettlementManager is the interface for a manager that is used to manage all settlement period policies. If a policy has a duration of 0, it means the policy is to reject.
type SettlementManagerImpl ¶
type SettlementManagerImpl struct {
// contains filtered or unexported fields
}
SettlementManagerImpl is the implementation of the SettlementManager interface.
func NewSettlementManagerImpl ¶
func NewSettlementManagerImpl(ctx context.Context, opts Opts) (*SettlementManagerImpl, error)
NewSettlementManagerImpl creates a new SettlementManagerImpl.
@input - context, options.
@output - settlement manager, error.
func (*SettlementManagerImpl) GetDefaultPolicy ¶
func (s *SettlementManagerImpl) GetDefaultPolicy(ctx context.Context, currencyID byte) (time.Duration, error)
GetDefaultPolicy gets the default settlement policy.
@input - context, currency id.
@output - settlement duration, error.
func (*SettlementManagerImpl) GetSenderPolicy ¶
func (s *SettlementManagerImpl) GetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) (time.Duration, error)
GetSenderPolicy gets the policy for a given currency id and sender pair.
@input - context, currency id, payment channel sender.
@output - settlement duration, error.
func (*SettlementManagerImpl) ListCurrencyIDs ¶
func (s *SettlementManagerImpl) ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)
ListCurrencyIDs lists all currency ids.
@input - context.
@output - currency id chan out, error chan out.
func (*SettlementManagerImpl) ListSenders ¶
func (s *SettlementManagerImpl) ListSenders(ctx context.Context, currencyID byte) (<-chan string, <-chan error)
ListSenders lists all senders with a policy set.
@input - context, currency id.
@output - sender chan out (could be default policy id or sender addr), error chan out.
func (*SettlementManagerImpl) RemoveDefaultPolicy ¶
func (s *SettlementManagerImpl) RemoveDefaultPolicy(ctx context.Context, currencyID byte) error
RemoveDefaultPolicy removes the default settlement policy.
@input - context, currency id.
@output - error.
func (*SettlementManagerImpl) RemoveSenderPolicy ¶
func (s *SettlementManagerImpl) RemoveSenderPolicy(ctx context.Context, currencyID byte, fromAddr string) error
RemoveSenderPolicy removes a policy.
@input - context, currency id, payment channel sender.
@output - error.
func (*SettlementManagerImpl) SetDefaultPolicy ¶
func (s *SettlementManagerImpl) SetDefaultPolicy(ctx context.Context, currencyID byte, duration time.Duration) error
SetDefaultPolicy sets the default settlement policy.
@input - context, currency id, settlement duration.
@output - error.
func (*SettlementManagerImpl) SetSenderPolicy ¶
func (s *SettlementManagerImpl) SetSenderPolicy(ctx context.Context, currencyID byte, fromAddr string, duration time.Duration) error
SetSenderPolicy sets a settlement policy for a given sender.
@input - context, currency id, payment channel sender, settlement duration.
@output - error.
func (*SettlementManagerImpl) Shutdown ¶
func (s *SettlementManagerImpl) Shutdown()
Shutdown safely shuts down the component.