From 80bc46e614129f6d8b8c4eabe42e2f7023d0aad8 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Fri, 30 Apr 2021 12:34:59 +0200 Subject: [PATCH] lint: fix proto message no-copy linter warnings --- chanacceptor/rpcacceptor.go | 10 +++++----- chanacceptor/rpcacceptor_test.go | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/chanacceptor/rpcacceptor.go b/chanacceptor/rpcacceptor.go index 2e92ba16..66d846b3 100644 --- a/chanacceptor/rpcacceptor.go +++ b/chanacceptor/rpcacceptor.go @@ -169,7 +169,7 @@ func (r *RPCAcceptor) Run() error { defer r.wg.Wait() // Create a channel that responses from acceptors are sent into. - responses := make(chan lnrpc.ChannelAcceptResponse) + responses := make(chan *lnrpc.ChannelAcceptResponse) // errChan is used by the receive loop to signal any errors that occur // during reading from the stream. This is primarily used to shutdown @@ -193,7 +193,7 @@ func (r *RPCAcceptor) Run() error { // dispatches them into the responses channel provided, sending any errors that // occur into the error channel provided. func (r *RPCAcceptor) receiveResponses(errChan chan error, - responses chan lnrpc.ChannelAcceptResponse) { + responses chan *lnrpc.ChannelAcceptResponse) { for { resp, err := r.receive() @@ -205,7 +205,7 @@ func (r *RPCAcceptor) receiveResponses(errChan chan error, var pendingID [32]byte copy(pendingID[:], resp.PendingChanId) - openChanResp := lnrpc.ChannelAcceptResponse{ + openChanResp := &lnrpc.ChannelAcceptResponse{ Accept: resp.Accept, PendingChanId: pendingID[:], Error: resp.Error, @@ -236,7 +236,7 @@ func (r *RPCAcceptor) receiveResponses(errChan chan error, // Accept() function, dispatching them to our acceptor stream and coordinating // return of responses to their callers. func (r *RPCAcceptor) sendAcceptRequests(errChan chan error, - responses chan lnrpc.ChannelAcceptResponse) error { + responses chan *lnrpc.ChannelAcceptResponse) error { // Close the done channel to indicate that the acceptor is no longer // listening and any in-progress requests should be terminated. @@ -332,7 +332,7 @@ func (r *RPCAcceptor) sendAcceptRequests(errChan chan error, // acceptor, returning a boolean indicating whether to accept the channel, an // error to send to the peer, and any validation errors that occurred. func (r *RPCAcceptor) validateAcceptorResponse(dustLimit btcutil.Amount, - req lnrpc.ChannelAcceptResponse) (bool, error, lnwire.DeliveryAddress, + req *lnrpc.ChannelAcceptResponse) (bool, error, lnwire.DeliveryAddress, error) { channelStr := hex.EncodeToString(req.PendingChanId) diff --git a/chanacceptor/rpcacceptor_test.go b/chanacceptor/rpcacceptor_test.go index d60180fa..9588775a 100644 --- a/chanacceptor/rpcacceptor_test.go +++ b/chanacceptor/rpcacceptor_test.go @@ -27,7 +27,7 @@ func TestValidateAcceptorResponse(t *testing.T) { tests := []struct { name string dustLimit btcutil.Amount - response lnrpc.ChannelAcceptResponse + response *lnrpc.ChannelAcceptResponse accept bool acceptorErr error error error @@ -35,7 +35,7 @@ func TestValidateAcceptorResponse(t *testing.T) { }{ { name: "accepted with error", - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: true, Error: customError.Error(), }, @@ -45,7 +45,7 @@ func TestValidateAcceptorResponse(t *testing.T) { }, { name: "custom error too long", - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: false, Error: strings.Repeat(" ", maxErrorLength+1), }, @@ -55,7 +55,7 @@ func TestValidateAcceptorResponse(t *testing.T) { }, { name: "accepted", - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: true, UpfrontShutdown: validAddr, }, @@ -66,7 +66,7 @@ func TestValidateAcceptorResponse(t *testing.T) { }, { name: "rejected with error", - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: false, Error: customError.Error(), }, @@ -76,7 +76,7 @@ func TestValidateAcceptorResponse(t *testing.T) { }, { name: "rejected with no error", - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: false, }, accept: false, @@ -85,7 +85,7 @@ func TestValidateAcceptorResponse(t *testing.T) { }, { name: "invalid upfront shutdown", - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: true, UpfrontShutdown: "invalid addr", }, @@ -96,7 +96,7 @@ func TestValidateAcceptorResponse(t *testing.T) { { name: "reserve too low", dustLimit: 100, - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: true, ReserveSat: 10, }, @@ -107,7 +107,7 @@ func TestValidateAcceptorResponse(t *testing.T) { { name: "max htlcs too high", dustLimit: 100, - response: lnrpc.ChannelAcceptResponse{ + response: &lnrpc.ChannelAcceptResponse{ Accept: true, MaxHtlcCount: 1 + input.MaxHTLCNumber/2, },