mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-24 06:47:44 +01:00
channeldb/migrations: touch up documentation
This commit is contained in:
parent
9f46727507
commit
93e5f9a545
1 changed files with 17 additions and 9 deletions
|
@ -386,17 +386,18 @@ func paymentStatusesMigration(tx *bolt.Tx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the bucket dedicated to storing statuses of payments,
|
// Get the bucket dedicated to storing statuses of payments,
|
||||||
// where a key is payment hash, value is payment status
|
// where a key is payment hash, value is payment status.
|
||||||
paymentStatuses, err := tx.CreateBucketIfNotExists(paymentStatusBucket)
|
paymentStatuses, err := tx.CreateBucketIfNotExists(paymentStatusBucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Migration database adds to all existing payments " +
|
log.Infof("Migrating database to support payment statuses -- " +
|
||||||
"statuses as Completed")
|
"marking all existing payments with status Completed")
|
||||||
|
|
||||||
// For each payment in the bucket, fetch all data.
|
// For each payment in the bucket, deserialize the payment and mark it
|
||||||
return bucket.ForEach(func(k, v []byte) error {
|
// as completed.
|
||||||
|
err = bucket.ForEach(func(k, v []byte) error {
|
||||||
// Ignores if it is sub-bucket.
|
// Ignores if it is sub-bucket.
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -411,9 +412,16 @@ func paymentStatusesMigration(tx *bolt.Tx) error {
|
||||||
// Calculate payment hash for current payment.
|
// Calculate payment hash for current payment.
|
||||||
paymentHash := sha256.Sum256(payment.PaymentPreimage[:])
|
paymentHash := sha256.Sum256(payment.PaymentPreimage[:])
|
||||||
|
|
||||||
// Tries to update status for current payment to completed
|
// Update status for current payment to completed. If it fails,
|
||||||
// if it fails - migration abort transaction and return payment bucket
|
// the migration is aborted and the payment bucket is returned
|
||||||
// to previous state.
|
// to its previous state.
|
||||||
return paymentStatuses.Put(paymentHash[:], StatusCompleted.Bytes())
|
return paymentStatuses.Put(paymentHash[:], StatusCompleted.Bytes())
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("Migration of payment statuses complete!")
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue