mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
watchtower: refactor getClientSession helper funcs
Small refactor to some of the tower client db helper functions in order to simplify upcoming commits.
This commit is contained in:
parent
707546e2f0
commit
3ac3b6a90d
1 changed files with 9 additions and 12 deletions
|
@ -1174,14 +1174,17 @@ func getClientSession(sessions, towers kvdb.RBucket,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Can't fail because client session body has already been read.
|
||||
sessionBkt := sessions.NestedReadBucket(idBytes)
|
||||
|
||||
// Fetch the committed updates for this session.
|
||||
commitedUpdates, err := getClientSessionCommits(sessions, idBytes)
|
||||
commitedUpdates, err := getClientSessionCommits(sessionBkt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Fetch the acked updates for this session.
|
||||
ackedUpdates, err := getClientSessionAcks(sessions, idBytes)
|
||||
ackedUpdates, err := getClientSessionAcks(sessionBkt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1195,11 +1198,8 @@ func getClientSession(sessions, towers kvdb.RBucket,
|
|||
|
||||
// getClientSessionCommits retrieves all committed updates for the session
|
||||
// identified by the serialized session id.
|
||||
func getClientSessionCommits(sessions kvdb.RBucket,
|
||||
idBytes []byte) ([]CommittedUpdate, error) {
|
||||
|
||||
// Can't fail because client session body has already been read.
|
||||
sessionBkt := sessions.NestedReadBucket(idBytes)
|
||||
func getClientSessionCommits(sessionBkt kvdb.RBucket) ([]CommittedUpdate,
|
||||
error) {
|
||||
|
||||
// Initialize commitedUpdates so that we can return an initialized map
|
||||
// if no committed updates exist.
|
||||
|
@ -1231,11 +1231,8 @@ func getClientSessionCommits(sessions kvdb.RBucket,
|
|||
|
||||
// getClientSessionAcks retrieves all acked updates for the session identified
|
||||
// by the serialized session id.
|
||||
func getClientSessionAcks(sessions kvdb.RBucket,
|
||||
idBytes []byte) (map[uint16]BackupID, error) {
|
||||
|
||||
// Can't fail because client session body has already been read.
|
||||
sessionBkt := sessions.NestedReadBucket(idBytes)
|
||||
func getClientSessionAcks(sessionBkt kvdb.RBucket) (map[uint16]BackupID,
|
||||
error) {
|
||||
|
||||
// Initialize ackedUpdates so that we can return an initialized map if
|
||||
// no acked updates exist.
|
||||
|
|
Loading…
Add table
Reference in a new issue