From 13c656defe3b1e78a520e7e7be660a4af4d3319d Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 20 Mar 2023 17:57:42 +0200 Subject: [PATCH] lnrpc: use new ExcludeExhaustedSessions option --- lnrpc/wtclientrpc/wtclient.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lnrpc/wtclientrpc/wtclient.go b/lnrpc/wtclientrpc/wtclient.go index 335c370c8..1f45335fb 100644 --- a/lnrpc/wtclientrpc/wtclient.go +++ b/lnrpc/wtclientrpc/wtclient.go @@ -269,7 +269,7 @@ func (c *WatchtowerClient) ListTowers(ctx context.Context, } opts, ackCounts, committedUpdateCounts := constructFunctionalOptions( - req.IncludeSessions, + req.IncludeSessions, req.ExcludeExhaustedSessions, ) anchorTowers, err := c.cfg.AnchorClient.RegisteredTowers(opts...) @@ -334,7 +334,7 @@ func (c *WatchtowerClient) GetTowerInfo(ctx context.Context, } opts, ackCounts, committedUpdateCounts := constructFunctionalOptions( - req.IncludeSessions, + req.IncludeSessions, req.ExcludeExhaustedSessions, ) // Get the tower and its sessions from anchors client. @@ -377,9 +377,9 @@ func (c *WatchtowerClient) GetTowerInfo(ctx context.Context, // functional options to be used when fetching a tower from the DB. It also // returns a map of acked-update counts and one for un-acked-update counts that // will be populated once the db call has been made. -func constructFunctionalOptions(includeSessions bool) ( - []wtdb.ClientSessionListOption, map[wtdb.SessionID]uint16, - map[wtdb.SessionID]uint16) { +func constructFunctionalOptions(includeSessions, + excludeExhaustedSessions bool) ([]wtdb.ClientSessionListOption, + map[wtdb.SessionID]uint16, map[wtdb.SessionID]uint16) { var ( opts []wtdb.ClientSessionListOption @@ -407,6 +407,12 @@ func constructFunctionalOptions(includeSessions bool) ( wtdb.WithPerCommittedUpdate(perCommittedUpdate), } + if excludeExhaustedSessions { + opts = append(opts, wtdb.WithPostEvalFilterFn( + wtclient.ExhaustedSessionFilter(), + )) + } + return opts, ackCounts, committedUpdateCounts }