routing: convert to node pair based

Previously mission control tracked failures on a per node, per channel basis.
This commit changes this to tracking on the level of directed node pairs. The goal
of moving to this coarser-grained level is to reduce the number of required
payment attempts without compromising payment reliability.
This commit is contained in:
Joost Jager
2019-07-29 15:10:58 +02:00
parent 6ee2c04190
commit f1769c8c8c
17 changed files with 1133 additions and 995 deletions

View File

@@ -451,40 +451,43 @@ func (s *Server) QueryMissionControl(ctx context.Context,
snapshot := s.cfg.RouterBackend.MissionControl.GetHistorySnapshot()
rpcNodes := make([]*NodeHistory, len(snapshot.Nodes))
for i, n := range snapshot.Nodes {
rpcNodes := make([]*NodeHistory, 0, len(snapshot.Nodes))
for _, n := range snapshot.Nodes {
// Copy node struct to prevent loop variable binding bugs.
node := n
channels := make([]*ChannelHistory, len(node.Channels))
for j, channel := range node.Channels {
channels[j] = &ChannelHistory{
ChannelId: channel.ChannelID,
LastFailTime: channel.LastFail.Unix(),
MinPenalizeAmtSat: int64(
channel.MinPenalizeAmt.ToSatoshis(),
),
SuccessProb: float32(channel.SuccessProb),
}
}
var lastFail int64
if node.LastFail != nil {
lastFail = node.LastFail.Unix()
}
rpcNodes[i] = &NodeHistory{
rpcNode := NodeHistory{
Pubkey: node.Node[:],
LastFailTime: lastFail,
OtherChanSuccessProb: float32(
node.OtherChanSuccessProb,
LastFailTime: node.LastFail.Unix(),
OtherSuccessProb: float32(
node.OtherSuccessProb,
),
Channels: channels,
}
rpcNodes = append(rpcNodes, &rpcNode)
}
rpcPairs := make([]*PairHistory, 0, len(snapshot.Pairs))
for _, p := range snapshot.Pairs {
// Prevent binding to loop variable.
pair := p
rpcPair := PairHistory{
NodeFrom: pair.Pair.From[:],
NodeTo: pair.Pair.To[:],
LastFailTime: pair.LastFail.Unix(),
MinPenalizeAmtSat: int64(
pair.MinPenalizeAmt.ToSatoshis(),
),
SuccessProb: float32(pair.SuccessProb),
}
rpcPairs = append(rpcPairs, &rpcPair)
}
response := QueryMissionControlResponse{
Nodes: rpcNodes,
Pairs: rpcPairs,
}
return &response, nil