channeldb/payments: touch up docs
This commit is contained in:
1 file changed
+14
-13
+14
-13
@@ -28,25 +28,26 @@ var (
|
|||||||
type PaymentStatus byte
|
type PaymentStatus byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// StatusGrounded is status where payment is initiated and received
|
// StatusGrounded is the status where a payment has never been
|
||||||
// an intermittent failure
|
// initiated, or has been initiated and received an intermittent
|
||||||
|
// failure.
|
||||||
StatusGrounded PaymentStatus = 0
|
StatusGrounded PaymentStatus = 0
|
||||||
|
|
||||||
// StatusInFlight is status where payment is initiated, but a response
|
// StatusInFlight is the status where a payment has been initiated, but
|
||||||
// has not been received
|
// a response has not been received.
|
||||||
StatusInFlight PaymentStatus = 1
|
StatusInFlight PaymentStatus = 1
|
||||||
|
|
||||||
// StatusCompleted is status where payment is initiated and complete
|
// StatusCompleted is the status where a payment has been initiated and
|
||||||
// a payment successfully
|
// the payment was completed successfully.
|
||||||
StatusCompleted PaymentStatus = 2
|
StatusCompleted PaymentStatus = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// Bytes returns status as slice of bytes
|
// Bytes returns status as slice of bytes.
|
||||||
func (ps PaymentStatus) Bytes() []byte {
|
func (ps PaymentStatus) Bytes() []byte {
|
||||||
return []byte{byte(ps)}
|
return []byte{byte(ps)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FromBytes sets status from slice of bytes
|
// FromBytes sets status from slice of bytes.
|
||||||
func (ps *PaymentStatus) FromBytes(status []byte) error {
|
func (ps *PaymentStatus) FromBytes(status []byte) error {
|
||||||
if len(status) != 1 {
|
if len(status) != 1 {
|
||||||
return errors.New("payment status is empty")
|
return errors.New("payment status is empty")
|
||||||
@@ -62,7 +63,7 @@ func (ps *PaymentStatus) FromBytes(status []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns readable representation of payment status
|
// String returns readable representation of payment status.
|
||||||
func (ps PaymentStatus) String() string {
|
func (ps PaymentStatus) String() string {
|
||||||
switch ps {
|
switch ps {
|
||||||
case StatusGrounded:
|
case StatusGrounded:
|
||||||
@@ -186,7 +187,7 @@ func (db *DB) DeleteAllPayments() error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePaymentStatus sets status for outgoing/finished payment to store status in
|
// UpdatePaymentStatus sets the payment status for outgoing/finished payments in
|
||||||
// local database.
|
// local database.
|
||||||
func (db *DB) UpdatePaymentStatus(paymentHash [32]byte, status PaymentStatus) error {
|
func (db *DB) UpdatePaymentStatus(paymentHash [32]byte, status PaymentStatus) error {
|
||||||
return db.Batch(func(tx *bolt.Tx) error {
|
return db.Batch(func(tx *bolt.Tx) error {
|
||||||
@@ -199,10 +200,10 @@ func (db *DB) UpdatePaymentStatus(paymentHash [32]byte, status PaymentStatus) er
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchPaymentStatus returns payment status for outgoing payment
|
// FetchPaymentStatus returns the payment status for outgoing payment.
|
||||||
// if status of the payment isn't found it set to default status "StatusGrounded".
|
// If status of the payment isn't found, it will default to "StatusGrounded".
|
||||||
func (db *DB) FetchPaymentStatus(paymentHash [32]byte) (PaymentStatus, error) {
|
func (db *DB) FetchPaymentStatus(paymentHash [32]byte) (PaymentStatus, error) {
|
||||||
// default status for all payments that wasn't recorded in database
|
// The default status for all payments that aren't recorded in database.
|
||||||
paymentStatus := StatusGrounded
|
paymentStatus := StatusGrounded
|
||||||
|
|
||||||
err := db.View(func(tx *bolt.Tx) error {
|
err := db.View(func(tx *bolt.Tx) error {
|
||||||
|
|||||||
Reference in new issue
Block a user