@@ -130,17 +130,17 @@ var (
130
130
"does not exist" )
131
131
)
132
132
133
- // KVStore implements persistence for payments and payment attempts.
134
- type KVStore struct {
133
+ // KVPaymentsDB implements persistence for payments and payment attempts.
134
+ type KVPaymentsDB struct {
135
135
paymentSeqMx sync.Mutex
136
136
currPaymentSeq uint64
137
137
storedPaymentSeq uint64
138
138
db * DB
139
139
}
140
140
141
- // NewKVStore creates a new instance of the KVStore .
142
- func NewKVStore (db * DB ) * KVStore {
143
- return & KVStore {
141
+ // NewKVPaymentsDB creates a new instance of the KVPaymentsDB .
142
+ func NewKVPaymentsDB (db * DB ) * KVPaymentsDB {
143
+ return & KVPaymentsDB {
144
144
db : db ,
145
145
}
146
146
}
@@ -149,7 +149,7 @@ func NewKVStore(db *DB) *KVStore {
149
149
// making sure it does not already exist as an in-flight payment. When this
150
150
// method returns successfully, the payment is guaranteed to be in the InFlight
151
151
// state.
152
- func (p * KVStore ) InitPayment (paymentHash lntypes.Hash ,
152
+ func (p * KVPaymentsDB ) InitPayment (paymentHash lntypes.Hash ,
153
153
info * PaymentCreationInfo ) error {
154
154
155
155
// Obtain a new sequence number for this payment. This is used
@@ -252,8 +252,8 @@ func (p *KVStore) InitPayment(paymentHash lntypes.Hash,
252
252
}
253
253
254
254
// DeleteFailedAttempts deletes all failed htlcs for a payment if configured
255
- // by the KVStore db.
256
- func (p * KVStore ) DeleteFailedAttempts (hash lntypes.Hash ) error {
255
+ // by the KVPaymentsDB db.
256
+ func (p * KVPaymentsDB ) DeleteFailedAttempts (hash lntypes.Hash ) error {
257
257
if ! p .db .keepFailedPaymentAttempts {
258
258
const failedHtlcsOnly = true
259
259
err := p .db .DeletePayment (hash , failedHtlcsOnly )
@@ -318,7 +318,7 @@ func deserializePaymentIndex(r io.Reader) (lntypes.Hash, error) {
318
318
319
319
// RegisterAttempt atomically records the provided HTLCAttemptInfo to the
320
320
// DB.
321
- func (p * KVStore ) RegisterAttempt (paymentHash lntypes.Hash ,
321
+ func (p * KVPaymentsDB ) RegisterAttempt (paymentHash lntypes.Hash ,
322
322
attempt * HTLCAttemptInfo ) (* MPPayment , error ) {
323
323
324
324
// Serialize the information before opening the db transaction.
@@ -467,7 +467,7 @@ func (p *KVStore) RegisterAttempt(paymentHash lntypes.Hash,
467
467
// After invoking this method, InitPayment should always return an error to
468
468
// prevent us from making duplicate payments to the same payment hash. The
469
469
// provided preimage is atomically saved to the DB for record keeping.
470
- func (p * KVStore ) SettleAttempt (hash lntypes.Hash ,
470
+ func (p * KVPaymentsDB ) SettleAttempt (hash lntypes.Hash ,
471
471
attemptID uint64 , settleInfo * HTLCSettleInfo ) (* MPPayment , error ) {
472
472
473
473
var b bytes.Buffer
@@ -480,7 +480,7 @@ func (p *KVStore) SettleAttempt(hash lntypes.Hash,
480
480
}
481
481
482
482
// FailAttempt marks the given payment attempt failed.
483
- func (p * KVStore ) FailAttempt (hash lntypes.Hash ,
483
+ func (p * KVPaymentsDB ) FailAttempt (hash lntypes.Hash ,
484
484
attemptID uint64 , failInfo * HTLCFailInfo ) (* MPPayment , error ) {
485
485
486
486
var b bytes.Buffer
@@ -493,7 +493,7 @@ func (p *KVStore) FailAttempt(hash lntypes.Hash,
493
493
}
494
494
495
495
// updateHtlcKey updates a database key for the specified htlc.
496
- func (p * KVStore ) updateHtlcKey (paymentHash lntypes.Hash ,
496
+ func (p * KVPaymentsDB ) updateHtlcKey (paymentHash lntypes.Hash ,
497
497
attemptID uint64 , key , value []byte ) (* MPPayment , error ) {
498
498
499
499
aid := make ([]byte , 8 )
@@ -561,7 +561,7 @@ func (p *KVStore) updateHtlcKey(paymentHash lntypes.Hash,
561
561
// payment failed. After invoking this method, InitPayment should return nil on
562
562
// its next call for this payment hash, allowing the switch to make a
563
563
// subsequent payment.
564
- func (p * KVStore ) Fail (paymentHash lntypes.Hash ,
564
+ func (p * KVPaymentsDB ) Fail (paymentHash lntypes.Hash ,
565
565
reason FailureReason ) (* MPPayment , error ) {
566
566
567
567
var (
@@ -585,7 +585,7 @@ func (p *KVStore) Fail(paymentHash lntypes.Hash,
585
585
586
586
// We mark the payment as failed as long as it is known. This
587
587
// lets the last attempt to fail with a terminal write its
588
- // failure to the KVStore without synchronizing with
588
+ // failure to the KVPaymentsDB without synchronizing with
589
589
// other attempts.
590
590
_ , err = fetchPaymentStatus (bucket )
591
591
if errors .Is (err , ErrPaymentNotInitiated ) {
@@ -618,7 +618,7 @@ func (p *KVStore) Fail(paymentHash lntypes.Hash,
618
618
}
619
619
620
620
// FetchPayment returns information about a payment from the database.
621
- func (p * KVStore ) FetchPayment (paymentHash lntypes.Hash ) (
621
+ func (p * KVPaymentsDB ) FetchPayment (paymentHash lntypes.Hash ) (
622
622
* MPPayment , error ) {
623
623
624
624
var payment * MPPayment
@@ -714,7 +714,7 @@ func fetchPaymentBucketUpdate(tx kvdb.RwTx, paymentHash lntypes.Hash) (
714
714
715
715
// nextPaymentSequence returns the next sequence number to store for a new
716
716
// payment.
717
- func (p * KVStore ) nextPaymentSequence () ([]byte , error ) {
717
+ func (p * KVPaymentsDB ) nextPaymentSequence () ([]byte , error ) {
718
718
p .paymentSeqMx .Lock ()
719
719
defer p .paymentSeqMx .Unlock ()
720
720
@@ -774,7 +774,7 @@ func fetchPaymentStatus(bucket kvdb.RBucket) (PaymentStatus, error) {
774
774
}
775
775
776
776
// FetchInFlightPayments returns all payments with status InFlight.
777
- func (p * KVStore ) FetchInFlightPayments () ([]* MPPayment , error ) {
777
+ func (p * KVPaymentsDB ) FetchInFlightPayments () ([]* MPPayment , error ) {
778
778
var (
779
779
inFlights []* MPPayment
780
780
start = time .Now ()
0 commit comments