From ef820cea9f57d1237b4bf7a74cb10ab8011a0227 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 22 Jul 2022 18:15:54 -0500 Subject: [PATCH] rpcserver: Address unused param linter complaints. --- internal/rpcserver/rpcserver.go | 38 ++++++++++---------- internal/rpcserver/rpcserverhandlers_test.go | 2 +- internal/rpcserver/rpcwebsocket.go | 20 +++++------ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/internal/rpcserver/rpcserver.go b/internal/rpcserver/rpcserver.go index 3f471cc2..16cd9cb4 100644 --- a/internal/rpcserver/rpcserver.go +++ b/internal/rpcserver/rpcserver.go @@ -1832,7 +1832,7 @@ func handleGetAddedNodeInfo(_ context.Context, s *Server, cmd interface{}) (inte } // handleGetBestBlock implements the getbestblock command. -func handleGetBestBlock(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetBestBlock(_ context.Context, s *Server, _ interface{}) (interface{}, error) { // All other "get block" commands give either the height, the hash, or // both but require the block SHA. This gets both for the best block. best := s.cfg.Chain.BestSnapshot() @@ -1844,7 +1844,7 @@ func handleGetBestBlock(_ context.Context, s *Server, cmd interface{}) (interfac } // handleGetBestBlockHash implements the getbestblockhash command. -func handleGetBestBlockHash(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetBestBlockHash(_ context.Context, s *Server, _ interface{}) (interface{}, error) { best := s.cfg.Chain.BestSnapshot() return best.Hash.String(), nil } @@ -2038,7 +2038,7 @@ func thresholdStateToAgendaStatus(state blockchain.ThresholdStateTuple) string { } // handleGetBlockchainInfo implements the getblockchaininfo command. -func handleGetBlockchainInfo(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetBlockchainInfo(_ context.Context, s *Server, _ interface{}) (interface{}, error) { chain := s.cfg.Chain best := chain.BestSnapshot() _, bestHeaderHeight := chain.BestHeader() @@ -2129,7 +2129,7 @@ func handleGetBlockchainInfo(_ context.Context, s *Server, cmd interface{}) (int } // handleGetBlockCount implements the getblockcount command. -func handleGetBlockCount(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetBlockCount(_ context.Context, s *Server, _ interface{}) (interface{}, error) { best := s.cfg.Chain.BestSnapshot() return best.Height, nil } @@ -2289,7 +2289,7 @@ func handleGetBlockSubsidy(_ context.Context, s *Server, cmd interface{}) (inter } // handleGetChainTips implements the getchaintips command. -func handleGetChainTips(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetChainTips(_ context.Context, s *Server, _ interface{}) (interface{}, error) { chainTips := s.cfg.Chain.ChainTips() result := make([]types.GetChainTipsResult, 0, len(chainTips)) for _, tip := range chainTips { @@ -2319,7 +2319,7 @@ func handleGetCurrentNet(_ context.Context, s *Server, cmd interface{}) (interfa } // handleGetDifficulty implements the getdifficulty command. -func handleGetDifficulty(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetDifficulty(_ context.Context, s *Server, _ interface{}) (interface{}, error) { best := s.cfg.Chain.BestSnapshot() return getDifficultyRatio(best.Bits, s.cfg.ChainParams), nil } @@ -2419,7 +2419,7 @@ func handleGetCFilterV2(_ context.Context, s *Server, cmd interface{}) (interfac // handleGetInfo implements the getinfo command. We only return the fields // that are not related to wallet functionality. -func handleGetInfo(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetInfo(_ context.Context, s *Server, _ interface{}) (interface{}, error) { best := s.cfg.Chain.BestSnapshot() ret := &types.InfoChainResult{ Version: int32(1000000*version.Major + 10000*version.Minor + @@ -2439,7 +2439,7 @@ func handleGetInfo(_ context.Context, s *Server, cmd interface{}) (interface{}, } // handleGetMempoolInfo implements the getmempoolinfo command. -func handleGetMempoolInfo(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetMempoolInfo(_ context.Context, s *Server, _ interface{}) (interface{}, error) { mempoolTxns := s.cfg.TxMempooler.TxDescs() var numBytes int64 @@ -2490,7 +2490,7 @@ func handleGetMiningInfo(ctx context.Context, s *Server, _ interface{}) (interfa } // handleGetNetTotals implements the getnettotals command. -func handleGetNetTotals(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetNetTotals(_ context.Context, s *Server, _ interface{}) (interface{}, error) { totalBytesRecv, totalBytesSent := s.cfg.ConnMgr.NetTotals() reply := &types.GetNetTotalsResult{ TotalBytesRecv: totalBytesRecv, @@ -2598,7 +2598,7 @@ func handleGetNetworkHashPS(_ context.Context, s *Server, cmd interface{}) (inte } // handleGetNetworkInfo implements the getnetworkinfo command. -func handleGetNetworkInfo(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetNetworkInfo(_ context.Context, s *Server, _ interface{}) (interface{}, error) { lAddrs := s.cfg.AddrManager.LocalAddresses() localAddrs := make([]types.LocalAddressesResult, len(lAddrs)) for idx, entry := range lAddrs { @@ -2626,7 +2626,7 @@ func handleGetNetworkInfo(_ context.Context, s *Server, cmd interface{}) (interf } // handleGetPeerInfo implements the getpeerinfo command. -func handleGetPeerInfo(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetPeerInfo(_ context.Context, s *Server, _ interface{}) (interface{}, error) { peers := s.cfg.ConnMgr.ConnectedPeers() syncPeerID := s.cfg.SyncMgr.SyncPeerID() infos := make([]*types.GetPeerInfoResult, 0, len(peers)) @@ -2917,7 +2917,7 @@ func handleGetRawTransaction(_ context.Context, s *Server, cmd interface{}) (int } // handleGetStakeDifficulty implements the getstakedifficulty command. -func handleGetStakeDifficulty(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetStakeDifficulty(_ context.Context, s *Server, _ interface{}) (interface{}, error) { chain := s.cfg.Chain best := chain.BestSnapshot() blockHeader, err := chain.HeaderByHeight(best.Height) @@ -3075,7 +3075,7 @@ func handleGetStakeVersions(_ context.Context, s *Server, cmd interface{}) (inte } // handleGetTicketPoolValue implements the getticketpoolvalue command. -func handleGetTicketPoolValue(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetTicketPoolValue(_ context.Context, s *Server, _ interface{}) (interface{}, error) { amt, err := s.cfg.Chain.TicketPoolValue() if err != nil { return nil, rpcInternalError(err.Error(), @@ -3609,7 +3609,7 @@ func handleGetTxOut(_ context.Context, s *Server, cmd interface{}) (interface{}, } // handleGetTxOutSetInfo returns statistics on the current unspent transaction output set. -func handleGetTxOutSetInfo(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleGetTxOutSetInfo(_ context.Context, s *Server, _ interface{}) (interface{}, error) { best := s.cfg.Chain.BestSnapshot() stats, err := s.cfg.Chain.FetchUtxoStats() if err != nil { @@ -3973,7 +3973,7 @@ func handleInvalidateBlock(_ context.Context, s *Server, cmd interface{}) (inter } // handleLiveTickets implements the livetickets command. -func handleLiveTickets(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleLiveTickets(_ context.Context, s *Server, _ interface{}) (interface{}, error) { lt, err := s.cfg.Chain.LiveTickets() if err != nil { return nil, rpcInternalError("Could not get live tickets "+ @@ -3989,7 +3989,7 @@ func handleLiveTickets(_ context.Context, s *Server, cmd interface{}) (interface } // handlePing implements the ping command. -func handlePing(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handlePing(_ context.Context, s *Server, _ interface{}) (interface{}, error) { // Ask server to ping \o_ nonce, err := wire.RandomUint64() if err != nil { @@ -4054,7 +4054,7 @@ func handleReconsiderBlock(_ context.Context, s *Server, cmd interface{}) (inter } // handleRegenTemplate implements the regentemplate command. -func handleRegenTemplate(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleRegenTemplate(_ context.Context, s *Server, _ interface{}) (interface{}, error) { bt := s.cfg.BlockTemplater if bt == nil { return nil, rpcInternalError("Node is not configured for mining", "") @@ -4179,7 +4179,7 @@ func handleSetGenerate(_ context.Context, s *Server, cmd interface{}) (interface } // handleStop implements the stop command. -func handleStop(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleStop(_ context.Context, s *Server, _ interface{}) (interface{}, error) { select { case s.requestProcessShutdown <- struct{}{}: default: @@ -4818,7 +4818,7 @@ func handleVerifyMessage(_ context.Context, s *Server, cmd interface{}) (interfa } // handleVersion implements the version command. -func handleVersion(_ context.Context, s *Server, cmd interface{}) (interface{}, error) { +func handleVersion(_ context.Context, _ *Server, _ interface{}) (interface{}, error) { runtimeVer := strings.ReplaceAll(runtime.Version(), ".", "-") buildMeta := version.NormalizeString(runtimeVer) build := version.NormalizeString(version.BuildMetadata) diff --git a/internal/rpcserver/rpcserverhandlers_test.go b/internal/rpcserver/rpcserverhandlers_test.go index b33d0091..6e8975ee 100644 --- a/internal/rpcserver/rpcserverhandlers_test.go +++ b/internal/rpcserver/rpcserverhandlers_test.go @@ -6566,7 +6566,7 @@ func TestHandleTicketFeeInfo(t *testing.T) { mockChain: func() *testRPCChain { var numCalls int chain := defaultMockRPCChain() - chain.heightRangeFn = func(startHeight, endHeight int64) ([]chainhash.Hash, error) { + chain.heightRangeFn = func(_, _ int64) ([]chainhash.Hash, error) { numCalls++ if numCalls > 1 { return nil, fmt.Errorf("unable to fetch block by height") diff --git a/internal/rpcserver/rpcwebsocket.go b/internal/rpcserver/rpcwebsocket.go index 79fc6b9b..b4fd59c9 100644 --- a/internal/rpcserver/rpcwebsocket.go +++ b/internal/rpcserver/rpcwebsocket.go @@ -2053,13 +2053,13 @@ func handleLoadTxFilter(wsc *wsClient, icmd interface{}) (interface{}, error) { // handleNotifyBlocks implements the notifyblocks command extension for // websocket connections. -func handleNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleNotifyBlocks(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.RegisterBlockUpdates(wsc) return nil, nil } // handleRebroadcastWinners implements the rebroadcastwinners command. -func handleRebroadcastWinners(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleRebroadcastWinners(wsc *wsClient, _ interface{}) (interface{}, error) { cfg := wsc.rpcServer.cfg bestHeight := cfg.Chain.BestSnapshot().Height blocks, err := cfg.Chain.TipGeneration() @@ -2091,14 +2091,14 @@ func handleRebroadcastWinners(wsc *wsClient, icmd interface{}) (interface{}, err // handleNotifyWork implements the notifywork command extension for // websocket connections. -func handleNotifyWork(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleNotifyWork(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.RegisterWorkUpdates(wsc) return nil, nil } // handleNotifyTSpend implements the notifytspend command extension for // websocket connections. -func handleNotifyTSpend(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleNotifyTSpend(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.RegisterTSpendUpdates(wsc) return nil, nil } @@ -2111,35 +2111,35 @@ func handleSession(wsc *wsClient, icmd interface{}) (interface{}, error) { // handleWinningTickets implements the notifywinningtickets command // extension for websocket connections. -func handleWinningTickets(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleWinningTickets(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.RegisterWinningTickets(wsc) return nil, nil } // handleNewTickets implements the notifynewtickets command extension for // websocket connections. -func handleNewTickets(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleNewTickets(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.RegisterNewTickets(wsc) return nil, nil } // handleStopNotifyBlocks implements the stopnotifyblocks command extension for // websocket connections. -func handleStopNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleStopNotifyBlocks(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.UnregisterBlockUpdates(wsc) return nil, nil } // handleStopNotifyWork implements the stopnotifywork command extension for // websocket connections. -func handleStopNotifyWork(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleStopNotifyWork(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.UnregisterWorkUpdates(wsc) return nil, nil } // handleStopNotifyTSpend implements the stopnotifytspend command extension for // websocket connections. -func handleStopNotifyTSpend(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleStopNotifyTSpend(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.UnregisterTSpendUpdates(wsc) return nil, nil } @@ -2159,7 +2159,7 @@ func handleNotifyNewTransactions(wsc *wsClient, icmd interface{}) (interface{}, // handleStopNotifyNewTransations implements the stopnotifynewtransactions // command extension for websocket connections. -func handleStopNotifyNewTransactions(wsc *wsClient, icmd interface{}) (interface{}, error) { +func handleStopNotifyNewTransactions(wsc *wsClient, _ interface{}) (interface{}, error) { wsc.rpcServer.ntfnMgr.UnregisterNewMempoolTxsUpdates(wsc) return nil, nil }