routing: return full htlc attempt from router
This commit is contained in:
4 files changed
+44
-29
No files matched your search
@@ -318,25 +318,30 @@ func (s *Server) SendToRoute(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
preimage, err := s.cfg.Router.SendToRoute(hash, route)
|
||||
// Pass route to the router. This call returns the full htlc attempt
|
||||
// information as it is stored in the database. It is possible that both
|
||||
// the attempt return value and err are non-nil. This can happen when
|
||||
// the attempt was already initiated before the error happened. In that
|
||||
// case, we give precedence to the attempt information as stored in the
|
||||
// db.
|
||||
attempt, err := s.cfg.Router.SendToRoute(hash, route)
|
||||
if attempt != nil {
|
||||
rpcAttempt, err := s.cfg.RouterBackend.MarshalHTLCAttempt(
|
||||
*attempt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// In the success case, return the preimage.
|
||||
if err == nil {
|
||||
return &SendToRouteResponse{
|
||||
Preimage: preimage[:],
|
||||
}, nil
|
||||
resp := &SendToRouteResponse{
|
||||
Preimage: rpcAttempt.Preimage,
|
||||
Failure: rpcAttempt.Failure,
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// In the failure case, marshall the failure message to the rpc format
|
||||
// before returning it to the caller.
|
||||
rpcErr, err := marshallError(err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SendToRouteResponse{
|
||||
Failure: rpcErr,
|
||||
}, nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// ResetMissionControl clears all mission control state and starts with a clean
|
||||
|
||||
Reference in new issue
Block a user