routing+routerrpc: also expose amt for success results in mc
This commit is contained in:
9 files changed
+187
-166
No files matched your search
@@ -128,11 +128,10 @@ type TimedPairResult struct {
|
||||
// timestamp is the time when this result was obtained.
|
||||
Timestamp time.Time
|
||||
|
||||
// minPenalizeAmt is the minimum amount for which a penalty should be
|
||||
// applied based on this result. Only applies to fail results.
|
||||
MinPenalizeAmt lnwire.MilliSatoshi
|
||||
// Amt is the amount that was forwarded in the last payment attempt.
|
||||
Amt lnwire.MilliSatoshi
|
||||
|
||||
// success indicates whether the payment attempt was successful through
|
||||
// Success indicates whether the payment attempt was successful through
|
||||
// this pair.
|
||||
Success bool
|
||||
}
|
||||
@@ -142,9 +141,9 @@ func newTimedPairResult(timestamp time.Time,
|
||||
result pairResult) TimedPairResult {
|
||||
|
||||
return TimedPairResult{
|
||||
Timestamp: timestamp,
|
||||
MinPenalizeAmt: result.minPenalizeAmt,
|
||||
Success: result.success,
|
||||
Timestamp: timestamp,
|
||||
Amt: result.amt,
|
||||
Success: result.success,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,8 +496,8 @@ func (m *MissionControl) applyPaymentResult(
|
||||
"Control: pair=%v", pair)
|
||||
} else {
|
||||
log.Debugf("Reporting pair failure to Mission "+
|
||||
"Control: pair=%v, minPenalizeAmt=%v",
|
||||
pair, pairResult.minPenalizeAmt)
|
||||
"Control: pair=%v, amt=%v",
|
||||
pair, pairResult.amt)
|
||||
}
|
||||
|
||||
m.setLastPairResult(
|
||||
|
||||
@@ -92,7 +92,7 @@ func (p *probabilityEstimator) getNodeProbability(now time.Time,
|
||||
// Weigh failures in accordance with their age. The base
|
||||
// probability of a failure is considered zero, so nothing needs
|
||||
// to be added to probabilitiesTotal.
|
||||
case amt >= result.MinPenalizeAmt:
|
||||
case amt >= result.Amt:
|
||||
totalWeight += p.getWeight(age)
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ func (p *probabilityEstimator) calculateProbability(
|
||||
// penalization. If the current amount is smaller than the amount that
|
||||
// previously triggered a failure, we act as if this is an untried
|
||||
// channel.
|
||||
if amt < lastPairResult.MinPenalizeAmt {
|
||||
if amt < lastPairResult.Amt {
|
||||
return nodeProbability
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ func TestProbabilityEstimatorOneSuccess(t *testing.T) {
|
||||
ctx.results = map[int]TimedPairResult{
|
||||
node1: newTimedPairResult(
|
||||
testTime.Add(-time.Hour),
|
||||
successPairResult(),
|
||||
successPairResult(100),
|
||||
),
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestProbabilityEstimatorMix(t *testing.T) {
|
||||
ctx.results = map[int]TimedPairResult{
|
||||
node1: newTimedPairResult(
|
||||
testTime.Add(-time.Hour),
|
||||
successPairResult(),
|
||||
successPairResult(100),
|
||||
),
|
||||
node2: newTimedPairResult(
|
||||
testTime.Add(-2*time.Hour),
|
||||
|
||||
@@ -17,9 +17,9 @@ var (
|
||||
// pairResult contains the result of the interpretation of a payment attempt for
|
||||
// a specific node pair.
|
||||
type pairResult struct {
|
||||
// minPenalizeAmt is the minimum amount for which a penalty should be
|
||||
// applied based on this result. Only applies to fail results.
|
||||
minPenalizeAmt lnwire.MilliSatoshi
|
||||
// amt is the amount that was forwarded for this pair. Can be set to
|
||||
// zero for failures that are amount independent.
|
||||
amt lnwire.MilliSatoshi
|
||||
|
||||
// success indicates whether the payment attempt was successful through
|
||||
// this pair.
|
||||
@@ -29,24 +29,28 @@ type pairResult struct {
|
||||
// failPairResult creates a new result struct for a failure.
|
||||
func failPairResult(minPenalizeAmt lnwire.MilliSatoshi) pairResult {
|
||||
return pairResult{
|
||||
minPenalizeAmt: minPenalizeAmt,
|
||||
amt: minPenalizeAmt,
|
||||
}
|
||||
}
|
||||
|
||||
// successPairResult creates a new result struct for a success.
|
||||
func successPairResult() pairResult {
|
||||
// newSuccessPairResult creates a new result struct for a success.
|
||||
func successPairResult(successAmt lnwire.MilliSatoshi) pairResult {
|
||||
return pairResult{
|
||||
success: true,
|
||||
amt: successAmt,
|
||||
}
|
||||
}
|
||||
|
||||
// String returns the human-readable representation of a pair result.
|
||||
func (p pairResult) String() string {
|
||||
var resultType string
|
||||
if p.success {
|
||||
return "success"
|
||||
resultType = "success"
|
||||
} else {
|
||||
resultType = "failed"
|
||||
}
|
||||
|
||||
return fmt.Sprintf("failed (minPenalizeAmt=%v)", p.minPenalizeAmt)
|
||||
return fmt.Sprintf("%v (amt=%v)", resultType, p.amt)
|
||||
}
|
||||
|
||||
// interpretedResult contains the result of the interpretation of a payment
|
||||
@@ -458,9 +462,9 @@ func (i *interpretedResult) successPairRange(
|
||||
rt *route.Route, fromIdx, toIdx int) {
|
||||
|
||||
for idx := fromIdx; idx <= toIdx; idx++ {
|
||||
pair, _ := getPair(rt, idx)
|
||||
pair, amt := getPair(rt, idx)
|
||||
|
||||
i.pairResults[pair] = successPairResult()
|
||||
i.pairResults[pair] = successPairResult(amt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ var resultTestCases = []resultTestCase{
|
||||
|
||||
expectedResult: &interpretedResult{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): successPairResult(),
|
||||
getTestPair(0, 1): successPairResult(100),
|
||||
getTestPair(1, 2): failPairResult(99),
|
||||
},
|
||||
},
|
||||
@@ -109,8 +109,8 @@ var resultTestCases = []resultTestCase{
|
||||
|
||||
expectedResult: &interpretedResult{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): successPairResult(),
|
||||
getTestPair(1, 2): successPairResult(),
|
||||
getTestPair(0, 1): successPairResult(100),
|
||||
getTestPair(1, 2): successPairResult(99),
|
||||
},
|
||||
finalFailureReason: &reasonIncorrectDetails,
|
||||
},
|
||||
@@ -124,7 +124,7 @@ var resultTestCases = []resultTestCase{
|
||||
|
||||
expectedResult: &interpretedResult{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): successPairResult(),
|
||||
getTestPair(0, 1): successPairResult(100),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -137,8 +137,8 @@ var resultTestCases = []resultTestCase{
|
||||
|
||||
expectedResult: &interpretedResult{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): successPairResult(),
|
||||
getTestPair(1, 2): successPairResult(),
|
||||
getTestPair(0, 1): successPairResult(100),
|
||||
getTestPair(1, 2): successPairResult(99),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -190,6 +190,7 @@ var resultTestCases = []resultTestCase{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): {
|
||||
success: true,
|
||||
amt: 100,
|
||||
},
|
||||
getTestPair(1, 2): {},
|
||||
getTestPair(2, 1): {},
|
||||
@@ -211,12 +212,15 @@ var resultTestCases = []resultTestCase{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): {
|
||||
success: true,
|
||||
amt: 100,
|
||||
},
|
||||
getTestPair(1, 2): {
|
||||
success: true,
|
||||
amt: 99,
|
||||
},
|
||||
getTestPair(2, 3): {
|
||||
success: true,
|
||||
amt: 97,
|
||||
},
|
||||
getTestPair(4, 3): {},
|
||||
},
|
||||
@@ -238,9 +242,11 @@ var resultTestCases = []resultTestCase{
|
||||
pairResults: map[DirectedNodePair]pairResult{
|
||||
getTestPair(0, 1): {
|
||||
success: true,
|
||||
amt: 100,
|
||||
},
|
||||
getTestPair(1, 2): {
|
||||
success: true,
|
||||
amt: 99,
|
||||
},
|
||||
getTestPair(3, 2): {},
|
||||
getTestPair(3, 4): {},
|
||||
|
||||
Reference in new issue
Block a user