lnrpc: use new ExcludeExhaustedSessions option

This commit is contained in:
Elle Mouton 2023-03-20 17:57:42 +02:00
parent e6494889b0
commit 13c656defe
No known key found for this signature in database
GPG Key ID: D7D916376026F177

View File

@ -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
}