watchtower/wtdb: return sorted ClientSession.CommittedUpdates
This commit replaces the map-based CommittedUpdates field with a slice. When reading from disk, these will already be sorted by bbolt, so the client restore the updates as presented without needing to sort them first. Since the key in the map variant was the sequence number, we refactor the CommittedUpdate struct to have a sequence number and an embedded CommittedUpdateBody (which is equivalent to the old CommittedUpdate). The database is then expected to populate the sequence number from the key on disk. Since the sequence number is now directly integrated in the CommittedUpdate struct, this allow allows us to remove the now redundant seqNum argument from CommitUpdate.
This commit is contained in:
4 files changed
+71
-84
No files matched your search
@@ -61,7 +61,7 @@ type DB interface {
|
||||
// hasn't been ACK'd by the tower. The sequence number of the update
|
||||
// should be exactly one greater than the existing entry, and less that
|
||||
// or equal to the session's MaxUpdates.
|
||||
CommitUpdate(id *wtdb.SessionID, seqNum uint16,
|
||||
CommitUpdate(id *wtdb.SessionID,
|
||||
update *wtdb.CommittedUpdate) (uint16, error)
|
||||
|
||||
// AckUpdate records an acknowledgment from the watchtower that the
|
||||
|
||||
Reference in new issue
Block a user