mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
watchtower: add DeleteSession method
Add a DeleteSession method to the tower client DB. This can be used to delete a closable session along with any references to the session.
This commit is contained in:
@@ -703,6 +703,34 @@ func (m *ClientDB) GetClientSession(id wtdb.SessionID,
|
||||
return &session, nil
|
||||
}
|
||||
|
||||
// DeleteSession can be called when a session should be deleted from the DB.
|
||||
// All references to the session will also be deleted from the DB. Note that a
|
||||
// session will only be deleted if it is considered closable.
|
||||
func (m *ClientDB) DeleteSession(id wtdb.SessionID) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
_, ok := m.closableSessions[id]
|
||||
if !ok {
|
||||
return wtdb.ErrSessionNotClosable
|
||||
}
|
||||
|
||||
// For each of the channels, delete the session ID entry.
|
||||
for chanID := range m.ackedUpdates[id] {
|
||||
c, ok := m.channels[chanID]
|
||||
if !ok {
|
||||
return wtdb.ErrChannelNotRegistered
|
||||
}
|
||||
|
||||
delete(c.sessions, id)
|
||||
}
|
||||
|
||||
delete(m.closableSessions, id)
|
||||
delete(m.activeSessions, id)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterChannel registers a channel for use within the client database. For
|
||||
// now, all that is stored in the channel summary is the sweep pkscript that
|
||||
// we'd like any tower sweeps to pay into. In the future, this will be extended
|
||||
|
||||
Reference in New Issue
Block a user