channeldb: remove redundant MPPaymentCreationInfo struct

MPPaymentCreationInfo and PaymentCreationInfo are identical except for
the naming of CreationTime/CreationDate.
This commit is contained in:
Joost Jager 2020-02-19 09:53:13 +01:00
parent 8a5d846f94
commit 967b4b2dc3
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
6 changed files with 14 additions and 31 deletions

@ -5,26 +5,9 @@ import (
"github.com/btcsuite/btcd/btcec"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
)
// MPPaymentCreationInfo is the information necessary to have ready when
// initiating a payment, moving it into state InFlight.
type MPPaymentCreationInfo struct {
// PaymentHash is the hash this payment is paying to.
PaymentHash lntypes.Hash
// Value is the amount we are paying.
Value lnwire.MilliSatoshi
// CreatingTime is the time at which this payment was started.
CreationTime time.Time
// PaymentRequest is the full payment request, if any.
PaymentRequest []byte
}
// HTLCAttempt contains information about a specific HTLC attempt for a given
// payment. This information is used by the router to handle any errors coming
// back after an attempt is made, and to query the switch about the status of a
@ -74,8 +57,8 @@ type HTLCFailInfo struct {
FailTime time.Time
}
// MPPayment is a wrapper around a payment's MPPaymentCreationInfo and
// HTLCAttempts. All payments will have the MPPPaymentCreationInfo set, any
// MPPayment is a wrapper around a payment's PaymentCreationInfo and
// HTLCAttempts. All payments will have the PaymentCreationInfo set, any
// HTLCs made in attempts to be completed will populated in the HTLCs slice.
// Each populated HTLCAttempt represents an attempted HTLC, each of which may
// have the associated Settle or Fail struct populated if the HTLC is no longer
@ -87,7 +70,7 @@ type MPPayment struct {
// Info holds all static information about this payment, and is
// populated when the payment is initiated.
Info *MPPaymentCreationInfo
Info *PaymentCreationInfo
// HTLCs holds the information about individual HTLCs that we send in
// order to make the payment.

@ -51,7 +51,7 @@ func genInfo() (*PaymentCreationInfo, *PaymentAttemptInfo,
return &PaymentCreationInfo{
PaymentHash: rhash,
Value: 1,
CreationDate: time.Unix(time.Now().Unix(), 0),
CreationTime: time.Unix(time.Now().Unix(), 0),
PaymentRequest: []byte("hola"),
},
&PaymentAttemptInfo{

@ -178,8 +178,8 @@ type PaymentCreationInfo struct {
// Value is the amount we are paying.
Value lnwire.MilliSatoshi
// CreatingDate is the time when this payment was initiated.
CreationDate time.Time
// CreationTime is the time when this payment was initiated.
CreationTime time.Time
// PaymentRequest is the full payment request, if any.
PaymentRequest []byte
@ -283,10 +283,10 @@ func (p *Payment) ToMPPayment() *MPPayment {
return &MPPayment{
sequenceNum: p.sequenceNum,
Info: &MPPaymentCreationInfo{
Info: &PaymentCreationInfo{
PaymentHash: p.Info.PaymentHash,
Value: p.Info.Value,
CreationTime: p.Info.CreationDate,
CreationTime: p.Info.CreationTime,
PaymentRequest: p.Info.PaymentRequest,
},
HTLCs: htlcs,
@ -475,7 +475,7 @@ func serializePaymentCreationInfo(w io.Writer, c *PaymentCreationInfo) error {
return err
}
byteOrder.PutUint64(scratch[:], uint64(c.CreationDate.Unix()))
byteOrder.PutUint64(scratch[:], uint64(c.CreationTime.Unix()))
if _, err := w.Write(scratch[:]); err != nil {
return err
}
@ -509,7 +509,7 @@ func deserializePaymentCreationInfo(r io.Reader) (*PaymentCreationInfo, error) {
if _, err := io.ReadFull(r, scratch[:]); err != nil {
return nil, err
}
c.CreationDate = time.Unix(int64(byteOrder.Uint64(scratch[:])), 0)
c.CreationTime = time.Unix(int64(byteOrder.Uint64(scratch[:])), 0)
if _, err := io.ReadFull(r, scratch[:4]); err != nil {
return nil, err

@ -62,7 +62,7 @@ func makeFakeInfo() (*PaymentCreationInfo, *PaymentAttemptInfo) {
Value: 1000,
// Use single second precision to avoid false positive test
// failures due to the monotonic time component.
CreationDate: time.Unix(time.Now().Unix(), 0),
CreationTime: time.Unix(time.Now().Unix(), 0),
PaymentRequest: []byte(""),
}

@ -311,7 +311,7 @@ func genInfo() (*channeldb.PaymentCreationInfo, *channeldb.PaymentAttemptInfo,
return &channeldb.PaymentCreationInfo{
PaymentHash: rhash,
Value: 1,
CreationDate: time.Unix(time.Now().Unix(), 0),
CreationTime: time.Unix(time.Now().Unix(), 0),
PaymentRequest: []byte("hola"),
},
&channeldb.PaymentAttemptInfo{

@ -1680,7 +1680,7 @@ func (r *ChannelRouter) preparePayment(payment *LightningPayment) (
info := &channeldb.PaymentCreationInfo{
PaymentHash: payment.PaymentHash,
Value: payment.Amount,
CreationDate: time.Now(),
CreationTime: time.Now(),
PaymentRequest: payment.PaymentRequest,
}
@ -1709,7 +1709,7 @@ func (r *ChannelRouter) SendToRoute(hash lntypes.Hash, route *route.Route) (
info := &channeldb.PaymentCreationInfo{
PaymentHash: hash,
Value: amt,
CreationDate: time.Now(),
CreationTime: time.Now(),
PaymentRequest: nil,
}