channeldb+routing: add new interface method TerminalInfo

This commit adds a new interface method `TerminalInfo` and changes its
implementation to return an `*HTLCAttempt` so it includes the route for
a successful payment. Method `GetFailureReason` is now removed as its
returned value can be found in the above method.
This commit is contained in:
yyforyongyu committed 2023-11-13 16:09:11 +08:00
1 parent 3c5c37b693
commit da8f1c084a
7 files changed
+59 -60

No files matched your search

+8 -10
View File
@@ -201,10 +201,10 @@ lifecycle:
ps := payment.GetState()
remainingFees := p.calcFeeBudget(ps.FeesPaid)
log.Debugf("Payment %v in state terminate=%v, "+
"active_shards=%v, rem_value=%v, fee_limit=%v",
p.identifier, payment.Terminated(),
ps.NumAttemptsInFlight, ps.RemainingAmt, remainingFees)
log.Debugf("Payment %v: status=%v, active_shards=%v, "+
"rem_value=%v, fee_limit=%v", p.identifier,
payment.GetStatus(), ps.NumAttemptsInFlight,
ps.RemainingAmt, remainingFees)
// We now proceed our lifecycle with the following tasks in
// order,
@@ -291,15 +291,13 @@ lifecycle:
"%v: %v", p.identifier, err)
}
// Find the first successful shard and return the preimage and route.
for _, a := range payment.GetHTLCs() {
if a.Settle != nil {
return a.Settle.Preimage, &a.Route, nil
}
htlc, failure := payment.TerminalInfo()
if htlc != nil {
return htlc.Settle.Preimage, &htlc.Route, nil
}
// Otherwise return the payment failure reason.
return [32]byte{}, nil, *payment.GetFailureReason()
return [32]byte{}, nil, *failure
}
// checkTimeout checks whether the payment has reached its timeout.