Skip to content

Commit 98a3594

Browse files
committed
fixup! multi: endpoints for onion messages
1 parent 91019b1 commit 98a3594

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

rpcserver.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9302,7 +9302,7 @@ func (r *rpcServer) SubscribeCustomMessages(
93029302
}
93039303

93049304
// SendOnionMessage sends a custom peer message.
9305-
func (r *rpcServer) SendOnionMessage(_ context.Context,
9305+
func (r *rpcServer) SendOnionMessage(ctx context.Context,
93069306
req *lnrpc.SendOnionMessageRequest) (*lnrpc.SendOnionMessageResponse,
93079307
error) {
93089308

@@ -9320,9 +9320,7 @@ func (r *rpcServer) SendOnionMessage(_ context.Context,
93209320
return nil, err
93219321
}
93229322

9323-
err = r.server.SendOnionMessage(
9324-
peer, blindingPoint, req.Onion,
9325-
)
9323+
err = r.server.SendOnionMessage(ctx, peer, blindingPoint, req.Onion)
93269324
switch {
93279325
case errors.Is(err, ErrPeerNotConnected):
93289326
return nil, status.Error(codes.NotFound, err.Error())

server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5319,21 +5319,24 @@ func (s *server) SendCustomMessage(peerPub [33]byte, msgType lnwire.MessageType,
53195319
// SendOnionMessage sends a custom message to the peer with the specified
53205320
// pubkey.
53215321
// TODO(gijs): change this message to include path finding.
5322-
func (s *server) SendOnionMessage(peerPub [33]byte,
5322+
func (s *server) SendOnionMessage(ctx context.Context, peerPub [33]byte,
53235323
blindingPoint *btcec.PublicKey, onion []byte) error {
53245324

53255325
peer, err := s.FindPeerByPubStr(string(peerPub[:]))
53265326
if err != nil {
53275327
return err
53285328
}
53295329

5330-
// We'll wait until the peer is active.
5330+
// We'll wait until the peer is active, but also listen for
5331+
// cancellation.
53315332
select {
53325333
case <-peer.ActiveSignal():
53335334
case <-peer.QuitSignal():
53345335
return fmt.Errorf("peer %x disconnected", peerPub)
53355336
case <-s.quit:
53365337
return ErrServerShuttingDown
5338+
case <-ctx.Done():
5339+
return ctx.Err()
53375340
}
53385341

53395342
msg := lnwire.NewOnionMessage(blindingPoint, onion)

0 commit comments

Comments
 (0)