mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 23:53:41 +02:00
rpcserver+channeldb: delete only failed payments if requested
This commit is contained in:
@@ -677,7 +677,7 @@ func fetchPaymentWithSequenceNumber(tx kvdb.RTx, paymentHash lntypes.Hash,
|
||||
}
|
||||
|
||||
// DeletePayments deletes all completed and failed payments from the DB.
|
||||
func (db *DB) DeletePayments() error {
|
||||
func (db *DB) DeletePayments(failedOnly bool) error {
|
||||
return kvdb.Update(db, func(tx kvdb.RwTx) error {
|
||||
payments := tx.ReadWriteBucket(paymentsRootBucket)
|
||||
if payments == nil {
|
||||
@@ -715,6 +715,12 @@ func (db *DB) DeletePayments() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If we requested to only delete failed payments, we
|
||||
// can return if this one is not.
|
||||
if failedOnly && paymentStatus != StatusFailed {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Add the bucket to the set of buckets we can delete.
|
||||
deleteBuckets = append(deleteBuckets, k)
|
||||
|
||||
|
Reference in New Issue
Block a user