mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 17:51:33 +02:00
wtclient: add TerminateSession method
This commit is contained in:
@@ -43,6 +43,10 @@ type ClientManager interface {
|
||||
// be used while the tower is inactive.
|
||||
DeactivateTower(pubKey *btcec.PublicKey) error
|
||||
|
||||
// TerminateSession sets the given session's status to CSessionTerminal
|
||||
// meaning that it will not be used again.
|
||||
TerminateSession(id wtdb.SessionID) error
|
||||
|
||||
// Stats returns the in-memory statistics of the client since startup.
|
||||
Stats() ClientStats
|
||||
|
||||
@@ -436,6 +440,23 @@ func (m *Manager) RemoveTower(key *btcec.PublicKey, addr net.Addr) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TerminateSession sets the given session's status to CSessionTerminal meaning
|
||||
// that it will not be used again.
|
||||
func (m *Manager) TerminateSession(id wtdb.SessionID) error {
|
||||
m.clientsMu.Lock()
|
||||
defer m.clientsMu.Unlock()
|
||||
|
||||
for _, client := range m.clients {
|
||||
err := client.terminateSession(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, mark the session as terminated in the DB.
|
||||
return m.cfg.DB.TerminateSession(id)
|
||||
}
|
||||
|
||||
// DeactivateTower sets the given tower's status to inactive so that it is not
|
||||
// considered for session negotiation. Its sessions will also not be used while
|
||||
// the tower is inactive.
|
||||
|
Reference in New Issue
Block a user