mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-30 09:40:24 +02:00
routing+htlcswitch: add new interface method HasAttemptResult
This commit is contained in:
parent
bbf58ab444
commit
b998ce11f1
@ -431,6 +431,21 @@ func (s *Switch) ProcessContractResolution(msg contractcourt.ResolutionMsg) erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasAttemptResult reads the network result store to fetch the specified
|
||||||
|
// attempt. Returns true if the attempt result exists.
|
||||||
|
func (s *Switch) HasAttemptResult(attemptID uint64) (bool, error) {
|
||||||
|
_, err := s.networkResults.getResult(attemptID)
|
||||||
|
if err == nil {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !errors.Is(err, ErrPaymentIDNotFound) {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetAttemptResult returns the result of the HTLC attempt with the given
|
// GetAttemptResult returns the result of the HTLC attempt with the given
|
||||||
// attemptID. The paymentHash should be set to the payment's overall hash, or
|
// attemptID. The paymentHash should be set to the payment's overall hash, or
|
||||||
// in case of AMP payments the payment's unique identifier.
|
// in case of AMP payments the payment's unique identifier.
|
||||||
|
@ -60,6 +60,12 @@ func (m *mockPaymentAttemptDispatcherOld) SendHTLC(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mockPaymentAttemptDispatcherOld) HasAttemptResult(
|
||||||
|
attemptID uint64) (bool, error) {
|
||||||
|
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *mockPaymentAttemptDispatcherOld) GetAttemptResult(paymentID uint64,
|
func (m *mockPaymentAttemptDispatcherOld) GetAttemptResult(paymentID uint64,
|
||||||
_ lntypes.Hash, _ htlcswitch.ErrorDecrypter) (
|
_ lntypes.Hash, _ htlcswitch.ErrorDecrypter) (
|
||||||
<-chan *htlcswitch.PaymentResult, error) {
|
<-chan *htlcswitch.PaymentResult, error) {
|
||||||
@ -209,6 +215,10 @@ func (m *mockPayerOld) SendHTLC(_ lnwire.ShortChannelID,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mockPayerOld) HasAttemptResult(attemptID uint64) (bool, error) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *mockPayerOld) GetAttemptResult(paymentID uint64, _ lntypes.Hash,
|
func (m *mockPayerOld) GetAttemptResult(paymentID uint64, _ lntypes.Hash,
|
||||||
_ htlcswitch.ErrorDecrypter) (<-chan *htlcswitch.PaymentResult, error) {
|
_ htlcswitch.ErrorDecrypter) (<-chan *htlcswitch.PaymentResult, error) {
|
||||||
|
|
||||||
@ -585,6 +595,13 @@ func (m *mockPaymentAttemptDispatcher) SendHTLC(firstHop lnwire.ShortChannelID,
|
|||||||
return args.Error(0)
|
return args.Error(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mockPaymentAttemptDispatcher) HasAttemptResult(
|
||||||
|
attemptID uint64) (bool, error) {
|
||||||
|
|
||||||
|
args := m.Called(attemptID)
|
||||||
|
return args.Bool(0), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *mockPaymentAttemptDispatcher) GetAttemptResult(attemptID uint64,
|
func (m *mockPaymentAttemptDispatcher) GetAttemptResult(attemptID uint64,
|
||||||
paymentHash lntypes.Hash, deobfuscator htlcswitch.ErrorDecrypter) (
|
paymentHash lntypes.Hash, deobfuscator htlcswitch.ErrorDecrypter) (
|
||||||
<-chan *htlcswitch.PaymentResult, error) {
|
<-chan *htlcswitch.PaymentResult, error) {
|
||||||
|
@ -135,6 +135,16 @@ type PaymentAttemptDispatcher interface {
|
|||||||
// NOTE: New payment attempts MUST NOT be made after the keepPids map
|
// NOTE: New payment attempts MUST NOT be made after the keepPids map
|
||||||
// has been created and this method has returned.
|
// has been created and this method has returned.
|
||||||
CleanStore(keepPids map[uint64]struct{}) error
|
CleanStore(keepPids map[uint64]struct{}) error
|
||||||
|
|
||||||
|
// HasAttemptResult reads the network result store to fetch the
|
||||||
|
// specified attempt. Returns true if the attempt result exists.
|
||||||
|
//
|
||||||
|
// NOTE: This method is used and should only be used by the router to
|
||||||
|
// resume payments during startup. It can be viewed as a subset of
|
||||||
|
// `GetAttemptResult` in terms of its functionality, and can be removed
|
||||||
|
// once we move the construction of `UpdateAddHTLC` and
|
||||||
|
// `ErrorDecrypter` into `htlcswitch`.
|
||||||
|
HasAttemptResult(attemptID uint64) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PaymentSessionSource is an interface that defines a source for the router to
|
// PaymentSessionSource is an interface that defines a source for the router to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user