Skip to content

Commit 9f08daf

Browse files
committed
accounts: let storeAccount set the LastUpdate timestamp
In later commits, we will use this `storeAccount` helper quite often. Instead of needing to remember to update the timestamp outside the call, it make sense to instead update the timestamp within the function. Yes this does mean that sometimes we make no overall changes but do update the timestamp but this is a pretty standard pattern that a "last updated" timestamp is updated at any point that we re-write a record (even if it does not have a net change).
1 parent 2012fba commit 9f08daf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

accounts/store_kvdb.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ func (s *BoltStore) NewAccount(ctx context.Context, balance lnwire.MilliSatoshi,
145145
InitialBalance: balance,
146146
CurrentBalance: int64(balance),
147147
ExpirationDate: expirationDate,
148-
LastUpdate: time.Now(),
149148
Invoices: make(AccountInvoices),
150149
Payments: make(AccountPayments),
151150
Label: label,
@@ -190,7 +189,6 @@ func (s *BoltStore) UpdateAccount(_ context.Context,
190189
return ErrAccountBucketNotFound
191190
}
192191

193-
account.LastUpdate = time.Now()
194192
return storeAccount(bucket, account)
195193
}, func() {})
196194
}
@@ -200,6 +198,8 @@ func (s *BoltStore) UpdateAccount(_ context.Context,
200198
func storeAccount(accountBucket kvdb.RwBucket,
201199
account *OffChainBalanceAccount) error {
202200

201+
account.LastUpdate = time.Now()
202+
203203
accountBinary, err := serializeAccount(account)
204204
if err != nil {
205205
return err

0 commit comments

Comments
 (0)