routing: persist mission control data

This commit is contained in:
Joost Jager committed 2019-07-31 08:44:00 +02:00
1 parent 3dc83d1b6b
commit 7e7b620355
14 files changed
+566 -28

No files matched your search

+4
View File
@@ -24,4 +24,8 @@ type RoutingConfig struct {
// executing a payment attempt that fails. It is used to trade off
// potentially better routes against their probability of succeeding.
AttemptCost btcutil.Amount `long:"attemptcost" description:"The (virtual) cost in sats of a failed payment attempt"`
// MaxMcHistory defines the maximum number of payment results that
// are held on disk by mission control.
MaxMcHistory int `long:"maxmchistory" description:"the maximum number of payment results that are held on disk by mission control"`
}
+2
View File
@@ -49,6 +49,7 @@ func DefaultConfig() *Config {
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
AttemptCost: routing.DefaultPaymentAttemptPenalty.
ToSatoshis(),
MaxMcHistory: routing.DefaultMaxMcHistory,
}
return &Config{
@@ -63,5 +64,6 @@ func GetRoutingConfig(cfg *Config) *RoutingConfig {
MinRouteProbability: cfg.MinRouteProbability,
AttemptCost: cfg.AttemptCost,
PenaltyHalfLife: cfg.PenaltyHalfLife,
MaxMcHistory: cfg.MaxMcHistory,
}
}
+1
View File
@@ -22,5 +22,6 @@ func GetRoutingConfig(cfg *Config) *RoutingConfig {
AttemptCost: routing.DefaultPaymentAttemptPenalty.
ToSatoshis(),
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
MaxMcHistory: routing.DefaultMaxMcHistory,
}
}
+1 -1
View File
@@ -64,7 +64,7 @@ type MissionControl interface {
// ResetHistory resets the history of MissionControl returning it to a state as
// if no payment attempts have been made.
ResetHistory()
ResetHistory() error
// GetHistorySnapshot takes a snapshot from the current mission control state
// and actual probability estimates.
+3 -1
View File
@@ -147,7 +147,9 @@ func (m *mockMissionControl) GetEdgeProbability(fromNode route.Vertex,
return testMissionControlProb
}
func (m *mockMissionControl) ResetHistory() {}
func (m *mockMissionControl) ResetHistory() error {
return nil
}
func (m *mockMissionControl) GetHistorySnapshot() *routing.MissionControlSnapshot {
return nil
+4 -1
View File
@@ -436,7 +436,10 @@ func marshallChannelUpdate(update *lnwire.ChannelUpdate) *ChannelUpdate {
func (s *Server) ResetMissionControl(ctx context.Context,
req *ResetMissionControlRequest) (*ResetMissionControlResponse, error) {
s.cfg.RouterBackend.MissionControl.ResetHistory()
err := s.cfg.RouterBackend.MissionControl.ResetHistory()
if err != nil {
return nil, err
}
return &ResetMissionControlResponse{}, nil
}