watchtower: add PostEvaluateFilterFn call-back option

This commit adds a new PostEvaluateFilterFn call-back option to
`wtdb.ClientSessionListCfg`. This call-back is run _after_ all the other
evaluation call-backs in `wtdb.ClientSessionListCfg` and is only used to
determine if the session should be included in the returned list or not.
This commit is contained in:
Elle Mouton committed 2023-03-20 20:14:01 +02:00
1 parent 7bc86ca42e
commit 49cd23725a
2 files changed
+33 -2

No files matched your search

+8 -2
View File
@@ -260,8 +260,6 @@ func (m *ClientDB) listClientSessions(tower *wtdb.TowerID,
continue
}
sessions[session.ID] = &session
if cfg.PerMaxHeight != nil {
for chanID, index := range m.ackedUpdates[session.ID] {
cfg.PerMaxHeight(
@@ -285,6 +283,14 @@ func (m *ClientDB) listClientSessions(tower *wtdb.TowerID,
cfg.PerCommittedUpdate(&session, &update)
}
}
if cfg.PostEvaluateFilterFn != nil &&
!cfg.PostEvaluateFilterFn(&session) {
continue
}
sessions[session.ID] = &session
}
return sessions, nil