notifications

package
v0.31.2-beta Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "NTFNS"

Subsystem defines the sub system name of this package.

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Client

type Client interface {
	// SubscribeNotifications subscribes to the notifications from the server.
	SubscribeNotifications(ctx context.Context,
		in *swapserverrpc.SubscribeNotificationsRequest,
		opts ...grpc.CallOption) (
		swapserverrpc.SwapServer_SubscribeNotificationsClient, error)
}

Client is the interface that the notification manager needs to implement in order to be able to subscribe to notifications.

type Config

type Config struct {
	// Client is the client used to communicate with the swap server.
	Client Client

	// CurrentToken returns the token that is currently contained in the
	// store or an l402.ErrNoToken error if there is none.
	CurrentToken func() (*l402.Token, error)

	// MinAliveConnTime is the minimum time that the connection to the
	// server needs to be alive before we consider it a successful.
	MinAliveConnTime time.Duration
}

Config contains all the services that the notification manager needs to operate.

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Manager is a manager for notifications that the swap server sends to the client.

func NewManager

func NewManager(cfg *Config) *Manager

NewManager creates a new notification manager.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

Run starts the notification manager. It will keep on running until the context is canceled. It will subscribe to notifications and forward them to the subscribers. On a first successful connection to the server, it will close the readyChan to signal that the manager is ready.

func (*Manager) SubscribeReservations

func (m *Manager) SubscribeReservations(ctx context.Context,
) <-chan *swapserverrpc.ServerReservationNotification

SubscribeReservations subscribes to the reservation notifications.

func (*Manager) SubscribeStaticLoopInSweepRequests

func (m *Manager) SubscribeStaticLoopInSweepRequests(ctx context.Context,
) <-chan *swapserverrpc.ServerStaticLoopInSweepNotification

SubscribeStaticLoopInSweepRequests subscribes to the static loop in sweep requests.

type NotificationType

type NotificationType int

NotificationType is the type of notification that the manager can handle.

const (
	// NotificationTypeUnknown is the default notification type.
	NotificationTypeUnknown NotificationType = iota

	// NotificationTypeReservation is the notification type for reservation
	// notifications.
	NotificationTypeReservation

	// NotificationTypeStaticLoopInSweepRequest is the notification type for
	// static loop in sweep requests.
	NotificationTypeStaticLoopInSweepRequest
)

Jump to

Keyboard shortcuts

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