From 9bd0dcd12103e592657db496c3371c25149995df Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 17 Mar 2023 10:00:54 +0800 Subject: [PATCH] rpcserver: add debug log for rpc calls --- rpcperms/interceptor.go | 4 ++++ rpcserver.go | 20 -------------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/rpcperms/interceptor.go b/rpcperms/interceptor.go index b96bc7f84..cea9670c4 100644 --- a/rpcperms/interceptor.go +++ b/rpcperms/interceptor.go @@ -772,6 +772,8 @@ func (r *InterceptorChain) rpcStateUnaryServerInterceptor() grpc.UnaryServerInte return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + r.rpcsLog.Debugf("[%v] requested", info.FullMethod) + if err := r.checkRPCState(info.Server); err != nil { return nil, err } @@ -786,6 +788,8 @@ func (r *InterceptorChain) rpcStateStreamServerInterceptor() grpc.StreamServerIn return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + r.rpcsLog.Debugf("[%v] requested", info.FullMethod) + if err := r.checkRPCState(srv); err != nil { return err } diff --git a/rpcserver.go b/rpcserver.go index cc8b95e06..f531e8a5b 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2941,8 +2941,6 @@ func (r *rpcServer) GetRecoveryInfo(ctx context.Context, func (r *rpcServer) ListPeers(ctx context.Context, in *lnrpc.ListPeersRequest) (*lnrpc.ListPeersResponse, error) { - rpcsLog.Tracef("[listpeers] request") - serverPeers := r.server.Peers() resp := &lnrpc.ListPeersResponse{ Peers: make([]*lnrpc.Peer, 0, len(serverPeers)), @@ -3701,8 +3699,6 @@ func (r *rpcServer) PendingChannels(ctx context.Context, in *lnrpc.PendingChannelsRequest) ( *lnrpc.PendingChannelsResponse, error) { - rpcsLog.Debugf("[pendingchannels]") - resp := &lnrpc.PendingChannelsResponse{} // First, we find all the channels that will soon be opened. @@ -6409,8 +6405,6 @@ func marshallTopologyChange(topChange *routing.TopologyChange) *lnrpc.GraphTopol func (r *rpcServer) ListPayments(ctx context.Context, req *lnrpc.ListPaymentsRequest) (*lnrpc.ListPaymentsResponse, error) { - rpcsLog.Debugf("[ListPayments]") - // If both dates are set, we check that the start date is less than the // end date, otherwise we'll get an empty result. if req.CreationDateStart != 0 && req.CreationDateEnd != 0 { @@ -6627,10 +6621,6 @@ const feeBase float64 = 1000000 func (r *rpcServer) FeeReport(ctx context.Context, _ *lnrpc.FeeReportRequest) (*lnrpc.FeeReportResponse, error) { - // TODO(roasbeef): use UnaryInterceptor to add automated logging - - rpcsLog.Debugf("[feereport]") - channelGraph := r.server.graphDB selfNode, err := channelGraph.SourceNode() if err != nil { @@ -6894,8 +6884,6 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context, req *lnrpc.ForwardingHistoryRequest) (*lnrpc.ForwardingHistoryResponse, error) { - rpcsLog.Debugf("[forwardinghistory]") - // Before we perform the queries below, we'll instruct the switch to // flush any pending events to disk. This ensure we get a complete // snapshot at this particular time. @@ -7426,8 +7414,6 @@ func (r *rpcServer) ChannelAcceptor(stream lnrpc.Lightning_ChannelAcceptorServer func (r *rpcServer) BakeMacaroon(ctx context.Context, req *lnrpc.BakeMacaroonRequest) (*lnrpc.BakeMacaroonResponse, error) { - rpcsLog.Debugf("[bakemacaroon]") - // If the --no-macaroons flag is used to start lnd, the macaroon service // is not initialized. Therefore we can't bake new macaroons. if r.macService == nil { @@ -7514,8 +7500,6 @@ func (r *rpcServer) ListMacaroonIDs(ctx context.Context, req *lnrpc.ListMacaroonIDsRequest) ( *lnrpc.ListMacaroonIDsResponse, error) { - rpcsLog.Debugf("[listmacaroonids]") - // If the --no-macaroons flag is used to start lnd, the macaroon service // is not initialized. Therefore we can't show any IDs. if r.macService == nil { @@ -7546,8 +7530,6 @@ func (r *rpcServer) DeleteMacaroonID(ctx context.Context, req *lnrpc.DeleteMacaroonIDRequest) ( *lnrpc.DeleteMacaroonIDResponse, error) { - rpcsLog.Debugf("[deletemacaroonid]") - // If the --no-macaroons flag is used to start lnd, the macaroon service // is not initialized. Therefore we can't delete any IDs. if r.macService == nil { @@ -7577,8 +7559,6 @@ func (r *rpcServer) ListPermissions(_ context.Context, _ *lnrpc.ListPermissionsRequest) (*lnrpc.ListPermissionsResponse, error) { - rpcsLog.Debugf("[listpermissions]") - permissionMap := make(map[string]*lnrpc.MacaroonPermissionList) for uri, perms := range r.interceptorChain.Permissions() { rpcPerms := make([]*lnrpc.MacaroonPermission, len(perms))