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:
2 files changed
+33
-2
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user