mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
channeldb: rename currPaymentSeq
This commit is contained in:
@@ -121,7 +121,7 @@ var (
|
|||||||
type KVPaymentsDB struct {
|
type KVPaymentsDB struct {
|
||||||
// Sequence management for the kv store.
|
// Sequence management for the kv store.
|
||||||
seqMu sync.Mutex
|
seqMu sync.Mutex
|
||||||
currPaymentSeq uint64
|
currSeq uint64
|
||||||
storedPaymentSeq uint64
|
storedPaymentSeq uint64
|
||||||
|
|
||||||
// db is the underlying database implementation.
|
// db is the underlying database implementation.
|
||||||
@@ -762,7 +762,7 @@ func (p *KVPaymentsDB) nextPaymentSequence() ([]byte, error) {
|
|||||||
|
|
||||||
// Set a new upper bound in the DB every 1000 payments to avoid
|
// Set a new upper bound in the DB every 1000 payments to avoid
|
||||||
// conflicts on the sequence when using etcd.
|
// conflicts on the sequence when using etcd.
|
||||||
if p.currPaymentSeq == p.storedPaymentSeq {
|
if p.currSeq == p.storedPaymentSeq {
|
||||||
var currPaymentSeq, newUpperBound uint64
|
var currPaymentSeq, newUpperBound uint64
|
||||||
if err := kvdb.Update(p.db, func(tx kvdb.RwTx) error {
|
if err := kvdb.Update(p.db, func(tx kvdb.RwTx) error {
|
||||||
paymentsBucket, err := tx.CreateTopLevelBucket(
|
paymentsBucket, err := tx.CreateTopLevelBucket(
|
||||||
@@ -785,16 +785,16 @@ func (p *KVPaymentsDB) nextPaymentSequence() ([]byte, error) {
|
|||||||
// initialize our stored currPaymentSeq, since by default both
|
// initialize our stored currPaymentSeq, since by default both
|
||||||
// this variable and storedPaymentSeq are zero which in turn
|
// this variable and storedPaymentSeq are zero which in turn
|
||||||
// will have us fetch the current values from the DB.
|
// will have us fetch the current values from the DB.
|
||||||
if p.currPaymentSeq == 0 {
|
if p.currSeq == 0 {
|
||||||
p.currPaymentSeq = currPaymentSeq
|
p.currSeq = currPaymentSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
p.storedPaymentSeq = newUpperBound
|
p.storedPaymentSeq = newUpperBound
|
||||||
}
|
}
|
||||||
|
|
||||||
p.currPaymentSeq++
|
p.currSeq++
|
||||||
b := make([]byte, 8)
|
b := make([]byte, 8)
|
||||||
binary.BigEndian.PutUint64(b, p.currPaymentSeq)
|
binary.BigEndian.PutUint64(b, p.currSeq)
|
||||||
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user