mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-07 11:22:10 +02:00
watchtower: update DeleteCommittedUpdate to delete all
This commit updates the DeleteCommittedUpdate DB method to delete all of a given session's committed updates instead of just one at a time. The reason for this is that in an upcoming commit, we will introduce a "Terminal" session state - once we have deleted a committed update for a session it should be considered "Terminal" and there is never a case where we would only want to delete one committed update and not the rest. So we want these two actions (deleting committed updates of a session and setting it's status to terminal) to be atomic.
This commit is contained in:
@@ -136,9 +136,9 @@ type DB interface {
|
||||
// space.
|
||||
GetDBQueue(namespace []byte) wtdb.Queue[*wtdb.BackupID]
|
||||
|
||||
// DeleteCommittedUpdate deletes the committed update belonging to the
|
||||
// given session and with the given sequence number from the db.
|
||||
DeleteCommittedUpdate(id *wtdb.SessionID, seqNum uint16) error
|
||||
// DeleteCommittedUpdates deletes all the committed updates belonging to
|
||||
// the given session from the db.
|
||||
DeleteCommittedUpdates(id *wtdb.SessionID) error
|
||||
}
|
||||
|
||||
// AuthDialer connects to a remote node using an authenticated transport, such
|
||||
|
@@ -211,14 +211,13 @@ func (q *sessionQueue) Stop(final bool) error {
|
||||
update.BackupID, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
err = q.cfg.DB.DeleteCommittedUpdate(
|
||||
q.ID(), update.SeqNum,
|
||||
)
|
||||
if final {
|
||||
err = q.cfg.DB.DeleteCommittedUpdates(q.ID())
|
||||
if err != nil {
|
||||
log.Errorf("could not delete committed "+
|
||||
"update %d for session %s",
|
||||
update.SeqNum, q.ID())
|
||||
"updates for session %s", q.ID())
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user