watchtower: add FetchSessionCommittedUpdates func to DB

In this commit, a new tower client db function is added that can be used
to fetch all the committed updates for a given session ID. This is done
in preparation for an upcoming commit where the CommittedUpdates will be
removed from the ClientSession struct.
This commit is contained in:
Elle Mouton committed 2022-10-13 14:39:23 +02:00
1 parent 15858cae1c
commit fe3d9174ea
4 files changed
+72 -4

No files matched your search

+16
View File
@@ -242,6 +242,22 @@ func (m *ClientDB) listClientSessions(tower *wtdb.TowerID,
return sessions, nil
}
// FetchSessionCommittedUpdates retrieves the current set of un-acked updates
// of the given session.
func (m *ClientDB) FetchSessionCommittedUpdates(id *wtdb.SessionID) (
[]wtdb.CommittedUpdate, error) {
m.mu.Lock()
defer m.mu.Unlock()
sess, ok := m.activeSessions[*id]
if !ok {
return nil, wtdb.ErrClientSessionNotFound
}
return sess.CommittedUpdates, nil
}
// CreateClientSession records a newly negotiated client session in the set of
// active sessions. The session can be identified by its SessionID.
func (m *ClientDB) CreateClientSession(session *wtdb.ClientSession) error {