watchtower+lnrpc: remove AckedUpdates from ClientSession struct
In this commit, we start making use of the new ListClientSession functional options added in the previous commit. We use the functional options in order to calculate the max commit heights per channel on the construction of the tower client. We also use the options to count the total number of acked and committed updates. With this commit, we are also able to completely remove the AckedUpdates member of the ClientSession since it is no longer used anywhere in the code.
This commit is contained in:
6 files changed
+194
-137
No files matched your search
@@ -1239,17 +1239,15 @@ func getClientSession(sessions, towers kvdb.RBucket, idBytes []byte,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Fetch the acked updates for this session.
|
||||
ackedUpdates, err := getClientSessionAcks(
|
||||
sessionBkt, session, cfg.PerAckedUpdate,
|
||||
)
|
||||
// Pass the session's acked updates through the call-back if one is
|
||||
// provided.
|
||||
err = filterClientSessionAcks(sessionBkt, session, cfg.PerAckedUpdate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
session.Tower = tower
|
||||
session.CommittedUpdates = commitedUpdates
|
||||
session.AckedUpdates = ackedUpdates
|
||||
|
||||
return session, nil
|
||||
}
|
||||
@@ -1292,18 +1290,19 @@ func getClientSessionCommits(sessionBkt kvdb.RBucket, s *ClientSession,
|
||||
return committedUpdates, nil
|
||||
}
|
||||
|
||||
// getClientSessionAcks retrieves all acked updates for the session identified
|
||||
// by the serialized session id.
|
||||
func getClientSessionAcks(sessionBkt kvdb.RBucket, s *ClientSession,
|
||||
cb PerAckedUpdateCB) (map[uint16]BackupID, error) {
|
||||
// filterClientSessionAcks retrieves all acked updates for the session
|
||||
// identified by the serialized session id and passes them to the provided
|
||||
// call back if one is provided.
|
||||
func filterClientSessionAcks(sessionBkt kvdb.RBucket, s *ClientSession,
|
||||
cb PerAckedUpdateCB) error {
|
||||
|
||||
// Initialize ackedUpdates so that we can return an initialized map if
|
||||
// no acked updates exist.
|
||||
ackedUpdates := make(map[uint16]BackupID)
|
||||
if cb == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
sessionAcks := sessionBkt.NestedReadBucket(cSessionAcks)
|
||||
if sessionAcks == nil {
|
||||
return ackedUpdates, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
err := sessionAcks.ForEach(func(k, v []byte) error {
|
||||
@@ -1315,19 +1314,14 @@ func getClientSessionAcks(sessionBkt kvdb.RBucket, s *ClientSession,
|
||||
return err
|
||||
}
|
||||
|
||||
ackedUpdates[seqNum] = backupID
|
||||
|
||||
if cb != nil {
|
||||
cb(s, seqNum, backupID)
|
||||
}
|
||||
|
||||
cb(s, seqNum, backupID)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
return ackedUpdates, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// putClientSessionBody stores the body of the ClientSession (everything but the
|
||||
|
||||
Reference in new issue
Block a user