routing+channeldb: use HTLCAttempt instead of HTLCAttemptInfo
This commit refactors the params used in lifecycle to prefer `HTLCAttempt` over `HTLCAttemptInfo`. This change is needed as `HTLCAttempt` also wraps settled and failure info, which is useful in the following commits.
This commit is contained in:
1 parent
a6be939bfa
commit
20e7e801c0
5 files changed
+30
-27
No files matched your search
@@ -47,15 +47,15 @@ type HTLCAttemptInfo struct {
|
||||
Hash *lntypes.Hash
|
||||
}
|
||||
|
||||
// NewHtlcAttemptInfo creates a htlc attempt.
|
||||
func NewHtlcAttemptInfo(attemptID uint64, sessionKey *btcec.PrivateKey,
|
||||
// NewHtlcAttempt creates a htlc attempt.
|
||||
func NewHtlcAttempt(attemptID uint64, sessionKey *btcec.PrivateKey,
|
||||
route route.Route, attemptTime time.Time,
|
||||
hash *lntypes.Hash) *HTLCAttemptInfo {
|
||||
hash *lntypes.Hash) *HTLCAttempt {
|
||||
|
||||
var scratch [btcec.PrivKeyBytesLen]byte
|
||||
copy(scratch[:], sessionKey.Serialize())
|
||||
|
||||
return &HTLCAttemptInfo{
|
||||
info := HTLCAttemptInfo{
|
||||
AttemptID: attemptID,
|
||||
sessionKey: scratch,
|
||||
cachedSessionKey: sessionKey,
|
||||
@@ -63,6 +63,8 @@ func NewHtlcAttemptInfo(attemptID uint64, sessionKey *btcec.PrivateKey,
|
||||
AttemptTime: attemptTime,
|
||||
Hash: hash,
|
||||
}
|
||||
|
||||
return &HTLCAttempt{HTLCAttemptInfo: info}
|
||||
}
|
||||
|
||||
// SessionKey returns the ephemeral key used for a htlc attempt. This function
|
||||
|
||||
@@ -38,7 +38,7 @@ func genInfo() (*PaymentCreationInfo, *HTLCAttemptInfo,
|
||||
}
|
||||
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
attempt := NewHtlcAttemptInfo(
|
||||
attempt := NewHtlcAttempt(
|
||||
0, priv, *testRoute.Copy(), time.Time{}, nil,
|
||||
)
|
||||
return &PaymentCreationInfo{
|
||||
@@ -46,7 +46,7 @@ func genInfo() (*PaymentCreationInfo, *HTLCAttemptInfo,
|
||||
Value: testRoute.ReceiverAmt(),
|
||||
CreationTime: time.Unix(time.Now().Unix(), 0),
|
||||
PaymentRequest: []byte("hola"),
|
||||
}, attempt, preimage, nil
|
||||
}, &attempt.HTLCAttemptInfo, preimage, nil
|
||||
}
|
||||
|
||||
// TestPaymentControlSwitchFail checks that payment status returns to Failed
|
||||
|
||||
@@ -69,11 +69,11 @@ func makeFakeInfo() (*PaymentCreationInfo, *HTLCAttemptInfo) {
|
||||
PaymentRequest: []byte(""),
|
||||
}
|
||||
|
||||
a := NewHtlcAttemptInfo(
|
||||
a := NewHtlcAttempt(
|
||||
44, priv, testRoute, time.Unix(100, 0), &hash,
|
||||
)
|
||||
|
||||
return c, a
|
||||
return c, &a.HTLCAttemptInfo
|
||||
}
|
||||
|
||||
func TestSentPaymentSerialization(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user