routerrpc: create pair data proto message

With a separate proto message, it becomes possible to also return the
pair data for a single pair. This prepares for the new mc probability
querying rpc.
This commit is contained in:
Joost Jager
2019-09-30 09:12:50 +02:00
parent 3d8adaef95
commit 04e7c98461
4 changed files with 204 additions and 145 deletions

View File

@@ -472,13 +472,9 @@ func (s *Server) QueryMissionControl(ctx context.Context,
pair := p
rpcPair := PairHistory{
NodeFrom: pair.Pair.From[:],
NodeTo: pair.Pair.To[:],
Timestamp: pair.Timestamp.Unix(),
MinPenalizeAmtSat: int64(
pair.MinPenalizeAmt.ToSatoshis(),
),
LastAttemptSuccessful: pair.Success,
NodeFrom: pair.Pair.From[:],
NodeTo: pair.Pair.To[:],
History: toRPCPairData(&pair.TimedPairResult),
}
rpcPairs = append(rpcPairs, &rpcPair)
@@ -491,6 +487,22 @@ func (s *Server) QueryMissionControl(ctx context.Context,
return &response, nil
}
// toRPCPairData marshalls mission control pair data to the rpc struct.
func toRPCPairData(data *routing.TimedPairResult) *PairData {
rpcData := PairData{
MinPenalizeAmtSat: int64(
data.MinPenalizeAmt.ToSatoshis(),
),
LastAttemptSuccessful: data.Success,
}
if !data.Timestamp.IsZero() {
rpcData.Timestamp = data.Timestamp.Unix()
}
return &rpcData
}
// TrackPayment returns a stream of payment state updates. The stream is
// closed when the payment completes.
func (s *Server) TrackPayment(request *TrackPaymentRequest,