File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -504,8 +504,8 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
504504
505505 // Start the notification manager.
506506 notificationCfg := & notifications.Config {
507- Client : loop_swaprpc .NewSwapServerClient (swapClient .Conn ),
508- FetchL402 : swapClient .Server . FetchL402 ,
507+ Client : loop_swaprpc .NewSwapServerClient (swapClient .Conn ),
508+ CurrentToken : swapClient .L402Store . CurrentToken ,
509509 }
510510 notificationManager := notifications .NewManager (notificationCfg )
511511
Original file line number Diff line number Diff line change 55 "sync"
66 "time"
77
8+ "github.com/lightninglabs/aperture/l402"
89 "github.com/lightninglabs/loop/swapserverrpc"
910 "google.golang.org/grpc"
1011)
@@ -37,8 +38,9 @@ type Config struct {
3738 // Client is the client used to communicate with the swap server.
3839 Client Client
3940
40- // FetchL402 is the function used to fetch the l402 token.
41- FetchL402 func (context.Context ) error
41+ // CurrentToken returns the token that is currently contained in the
42+ // store or an l402.ErrNoToken error if there is none.
43+ CurrentToken func () (* l402.Token , error )
4244}
4345
4446// Manager is a manager for notifications that the swap server sends to the
@@ -113,9 +115,13 @@ func (m *Manager) Run(ctx context.Context) error {
113115 // the FetchL402 method. As a client might not have outbound capacity
114116 // yet, we'll retry until we get a valid response.
115117 if ! m .hasL402 {
116- err := m .cfg .FetchL402 ( ctx )
118+ _ , err := m .cfg .CurrentToken ( )
117119 if err != nil {
118- log .Errorf ("Error fetching L402: %v" , err )
120+ // We only log the error if it's not the case that we
121+ // don't have a token yet to avoid spamming the logs.
122+ if err != l402 .ErrNoToken {
123+ log .Errorf ("Error getting L402 from store: %v" , err )
124+ }
119125 continue
120126 }
121127 m .hasL402 = true
Original file line number Diff line number Diff line change 77 "testing"
88 "time"
99
10+ "github.com/lightninglabs/aperture/l402"
1011 "github.com/lightninglabs/loop/swapserverrpc"
1112 "github.com/stretchr/testify/require"
1213 "google.golang.org/grpc"
@@ -101,9 +102,9 @@ func TestManager_ReservationNotification(t *testing.T) {
101102 // Create a Manager with the mock client
102103 mgr := NewManager (& Config {
103104 Client : mockClient ,
104- FetchL402 : func (ctx context. Context ) error {
105+ CurrentToken : func () ( * l402. Token , error ) {
105106 // Simulate successful fetching of L402
106- return nil
107+ return nil , nil
107108 },
108109 })
109110
You can’t perform that action at this time.
0 commit comments