diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fb537d489..3df22ee8a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -23,7 +23,7 @@ jobs: - uses: golangci/golangci-lint-action@v2.2.1 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.30 + version: v1.31 args: --timeout 10m github-token: ${{ secrets.github_token }} if: env.GIT_DIFF diff --git a/abci/example/kvstore/persistent_kvstore.go b/abci/example/kvstore/persistent_kvstore.go index 93676bdde..c2232cc77 100644 --- a/abci/example/kvstore/persistent_kvstore.go +++ b/abci/example/kvstore/persistent_kvstore.go @@ -212,7 +212,7 @@ func isValidatorTx(tx []byte) bool { func (app *PersistentKVStoreApplication) execValidatorTx(tx []byte) types.ResponseDeliverTx { tx = tx[len(ValidatorSetChangePrefix):] - //get the pubkey and power + // get the pubkey and power pubKeyAndPower := strings.Split(string(tx), "!") if len(pubKeyAndPower) != 2 { return types.ResponseDeliverTx{ diff --git a/abci/tests/test_app/main.go b/abci/tests/test_app/main.go index 32d04311f..1dcab1de1 100644 --- a/abci/tests/test_app/main.go +++ b/abci/tests/test_app/main.go @@ -69,7 +69,7 @@ func testCounter() { }() if err := ensureABCIIsUp(abciType, maxABCIConnectTries); err != nil { - log.Fatalf("echo failed: %v", err) + log.Fatalf("echo failed: %v", err) //nolint:gocritic } client := startClient(abciType) diff --git a/abci/types/util.go b/abci/types/util.go index 94a34c0c1..8205fef7e 100644 --- a/abci/types/util.go +++ b/abci/types/util.go @@ -27,7 +27,5 @@ func (v ValidatorUpdates) Less(i, j int) bool { } func (v ValidatorUpdates) Swap(i, j int) { - v1 := v[i] - v[i] = v[j] - v[j] = v1 + v[i], v[j] = v[j], v[i] } diff --git a/blockchain/v0/pool.go b/blockchain/v0/pool.go index 8cba75024..69e0b55c4 100644 --- a/blockchain/v0/pool.go +++ b/blockchain/v0/pool.go @@ -509,7 +509,7 @@ type bpRequester struct { pool *BlockPool height int64 gotBlockCh chan struct{} - redoCh chan p2p.ID //redo may send multitime, add peerId to identify repeat + redoCh chan p2p.ID // redo may send multitime, add peerId to identify repeat mtx tmsync.Mutex peerID p2p.ID @@ -601,7 +601,7 @@ OUTER_LOOP: } peer = bpr.pool.pickIncrAvailablePeer(bpr.height) if peer == nil { - //log.Info("No peers available", "height", height) + // log.Info("No peers available", "height", height) time.Sleep(requestIntervalMS * time.Millisecond) continue PICK_PEER_LOOP } diff --git a/blockchain/v0/pool_test.go b/blockchain/v0/pool_test.go index 36fb3e3c7..1653fe74a 100644 --- a/blockchain/v0/pool_test.go +++ b/blockchain/v0/pool_test.go @@ -22,7 +22,7 @@ type testPeer struct { id p2p.ID base int64 height int64 - inputChan chan inputData //make sure each peer's data is sequential + inputChan chan inputData // make sure each peer's data is sequential } type inputData struct { diff --git a/blockchain/v0/reactor.go b/blockchain/v0/reactor.go index 093e08241..440a6090c 100644 --- a/blockchain/v0/reactor.go +++ b/blockchain/v0/reactor.go @@ -346,7 +346,7 @@ FOR_LOOP: // See if there are any blocks to sync. first, second := bcR.pool.PeekTwoBlocks() - //bcR.Logger.Info("TrySync peeked", "first", first, "second", second) + // bcR.Logger.Info("TrySync peeked", "first", first, "second", second) if first == nil || second == nil { // We need both to sync the first block. continue FOR_LOOP diff --git a/blockchain/v0/reactor_test.go b/blockchain/v0/reactor_test.go index 4451a1c74..a88b499f4 100644 --- a/blockchain/v0/reactor_test.go +++ b/blockchain/v0/reactor_test.go @@ -247,7 +247,7 @@ func TestBadBlockStopsPeer(t *testing.T) { } } - //at this time, reactors[0-3] is the newest + // at this time, reactors[0-3] is the newest assert.Equal(t, 3, reactorPairs[1].reactor.Switch.Peers().Size()) // Mark reactorPairs[3] as an invalid peer. Fiddling with .store without a mutex is a data diff --git a/blockchain/v1/reactor.go b/blockchain/v1/reactor.go index 30bd4dd8a..780e43738 100644 --- a/blockchain/v1/reactor.go +++ b/blockchain/v1/reactor.go @@ -100,7 +100,7 @@ func NewBlockchainReactor(state sm.State, blockExec *sm.BlockExecutor, store *st fsm := NewFSM(startHeight, bcR) bcR.fsm = fsm bcR.BaseReactor = *p2p.NewBaseReactor("BlockchainReactor", bcR) - //bcR.swReporter = behaviour.NewSwitchReporter(bcR.BaseReactor.Switch) + // bcR.swReporter = behaviour.NewSwitchReporter(bcR.BaseReactor.Switch) return bcR } diff --git a/blockchain/v1/reactor_test.go b/blockchain/v1/reactor_test.go index 6bc5646a0..c0f371905 100644 --- a/blockchain/v1/reactor_test.go +++ b/blockchain/v1/reactor_test.go @@ -305,10 +305,10 @@ outerFor: break } - //at this time, reactors[0-3] is the newest + // at this time, reactors[0-3] is the newest assert.Equal(t, numNodes-1, reactorPairs[1].bcR.Switch.Peers().Size()) - //mark last reactorPair as an invalid peer + // mark last reactorPair as an invalid peer reactorPairs[numNodes-1].bcR.store = otherChain.bcR.store lastLogger := log.TestingLogger() diff --git a/blockchain/v2/scheduler.go b/blockchain/v2/scheduler.go index b97ee2f64..811a74bae 100644 --- a/blockchain/v2/scheduler.go +++ b/blockchain/v2/scheduler.go @@ -210,7 +210,7 @@ func newScheduler(initHeight int64, startTime time.Time) *scheduler { receivedBlocks: make(map[int64]p2p.ID), targetPending: 10, // TODO - pass as param peerTimeout: 15 * time.Second, // TODO - pass as param - minRecvRate: 0, //int64(7680), TODO - pass as param + minRecvRate: 0, // int64(7680), TODO - pass as param } return &sc @@ -532,9 +532,7 @@ func (peers PeerByID) Less(i, j int) bool { } func (peers PeerByID) Swap(i, j int) { - it := peers[i] - peers[i] = peers[j] - peers[j] = it + peers[i], peers[j] = peers[j], peers[i] } // Handlers diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 6a2f7cadd..4d6660210 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -112,7 +112,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { require.NoError(t, err) blocksSubs = append(blocksSubs, blocksSub) - if css[i].state.LastBlockHeight == 0 { //simulate handle initChain in handshake + if css[i].state.LastBlockHeight == 0 { // simulate handle initChain in handshake err = css[i].blockExec.Store().Save(css[i].state) require.NoError(t, err) } @@ -276,7 +276,7 @@ func TestByzantineConflictingProposalsWithPartition(t *testing.T) { } reactors[i] = conRI - err = css[i].blockExec.Store().Save(css[i].state) //for save height 1's validators info + err = css[i].blockExec.Store().Save(css[i].state) // for save height 1's validators info require.NoError(t, err) } diff --git a/consensus/common_test.go b/consensus/common_test.go index 5a87ce402..948812225 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -391,7 +391,7 @@ func newStateWithConfigAndBlockStore( // Make State stateDB := blockDB stateStore := sm.NewStore(stateDB) - if err := stateStore.Save(state); err != nil { //for save height 1's validators info + if err := stateStore.Save(state); err != nil { // for save height 1's validators info panic(err) } @@ -749,7 +749,7 @@ func randConsensusNetWithPeers( state.Version.Consensus.App = kvstore.ProtocolVersion } app.InitChain(abci.RequestInitChain{Validators: vals}) - //sm.SaveState(stateDB,state) //height 1's validatorsInfo already saved in LoadStateFromDBOrGenesisDoc above + // sm.SaveState(stateDB,state) //height 1's validatorsInfo already saved in LoadStateFromDBOrGenesisDoc above css[i] = newStateWithConfig(thisConfig, state, privVal, app) css[i].SetTimeoutTicker(tickerFunc()) diff --git a/consensus/reactor.go b/consensus/reactor.go index 85bea723c..c4a2ef9fd 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -540,7 +540,8 @@ OUTER_LOOP: // If height and round don't match, sleep. if (rs.Height != prs.Height) || (rs.Round != prs.Round) { - //logger.Info("Peer Height|Round mismatch, sleeping", "peerHeight", prs.Height, "peerRound", prs.Round, "peer", peer) + // logger.Info("Peer Height|Round mismatch, sleeping", + // "peerHeight", prs.Height, "peerRound", prs.Round, "peer", peer) time.Sleep(conR.conS.config.PeerGossipSleepDuration) continue OUTER_LOOP } @@ -622,7 +623,7 @@ func (conR *Reactor) gossipDataForCatchup(logger log.Logger, rs *cstypes.RoundSt } return } - //logger.Info("No parts to send in catch-up, sleeping") + // logger.Info("No parts to send in catch-up, sleeping") time.Sleep(conR.conS.config.PeerGossipSleepDuration) } @@ -649,8 +650,8 @@ OUTER_LOOP: sleeping = 0 } - //logger.Debug("gossipVotesRoutine", "rsHeight", rs.Height, "rsRound", rs.Round, - // "prsHeight", prs.Height, "prsRound", prs.Round, "prsStep", prs.Step) + // logger.Debug("gossipVotesRoutine", "rsHeight", rs.Height, "rsRound", rs.Round, + // "prsHeight", prs.Height, "prsRound", prs.Round, "prsStep", prs.Step) // If height matches, then send LastCommit, Prevotes, Precommits. if rs.Height == prs.Height { @@ -1488,7 +1489,7 @@ func (m *NewRoundStepMessage) String() string { //------------------------------------- // NewValidBlockMessage is sent when a validator observes a valid block B in some round r, -//i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. +// i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. // In case the block is also committed, then IsCommit flag is set to true. type NewValidBlockMessage struct { Height int64 diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index ce08daab4..192622e43 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -65,7 +65,7 @@ func startConsensusNet(t *testing.T, css []*State, n int) ( require.NoError(t, err) blocksSubs = append(blocksSubs, blocksSub) - if css[i].state.LastBlockHeight == 0 { //simulate handle initChain in handshake + if css[i].state.LastBlockHeight == 0 { // simulate handle initChain in handshake if err := css[i].blockExec.Store().Save(css[i].state); err != nil { t.Error(err) } diff --git a/consensus/replay.go b/consensus/replay.go index 6b7cad83d..bfec9e96d 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -323,7 +323,7 @@ func (h *Handshaker) ReplayBlocks( appHash = res.AppHash - if stateBlockHeight == 0 { //we only update state when we are in initial state + if stateBlockHeight == 0 { // we only update state when we are in initial state // If the app did not return an app hash, we keep the one set from the genesis doc in // the state. We don't set appHash since we don't want the genesis doc app hash // recorded in the genesis block. We should probably just remove GenesisDoc.AppHash. diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 5f279e330..2970f15ed 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -353,9 +353,7 @@ func TestSimulateValidatorsChange(t *testing.T) { signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) ensureNewRound(newRoundCh, height+1, 0) - ///////////////////////////////////////////////////////////////////////////// // HEIGHT 2 - ///////////////////////////////////////////////////////////////////////////// height++ incrementHeight(vss...) newValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() @@ -365,7 +363,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ := css[0].createProposalBlock() //changeProposer(t, cs1, vs2) + propBlock, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts := propBlock.MakePartSet(partSize) blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} @@ -385,9 +383,7 @@ func TestSimulateValidatorsChange(t *testing.T) { signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) ensureNewRound(newRoundCh, height+1, 0) - ///////////////////////////////////////////////////////////////////////////// // HEIGHT 3 - ///////////////////////////////////////////////////////////////////////////// height++ incrementHeight(vss...) updateValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() @@ -397,7 +393,7 @@ func TestSimulateValidatorsChange(t *testing.T) { updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2) + propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} @@ -417,9 +413,7 @@ func TestSimulateValidatorsChange(t *testing.T) { signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) ensureNewRound(newRoundCh, height+1, 0) - ///////////////////////////////////////////////////////////////////////////// // HEIGHT 4 - ///////////////////////////////////////////////////////////////////////////// height++ incrementHeight(vss...) newValidatorPubKey2, err := css[nVals+1].privValidator.GetPubKey() @@ -436,7 +430,7 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2) + propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss := make([]*validatorStub, nVals+1) @@ -487,9 +481,7 @@ func TestSimulateValidatorsChange(t *testing.T) { ensureNewRound(newRoundCh, height+1, 0) - ///////////////////////////////////////////////////////////////////////////// // HEIGHT 5 - ///////////////////////////////////////////////////////////////////////////// height++ incrementHeight(vss...) // Reflect the changes to vss[nVals] at height 3 and resort newVss. @@ -507,15 +499,13 @@ func TestSimulateValidatorsChange(t *testing.T) { } ensureNewRound(newRoundCh, height+1, 0) - ///////////////////////////////////////////////////////////////////////////// // HEIGHT 6 - ///////////////////////////////////////////////////////////////////////////// height++ incrementHeight(vss...) removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2) + propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) propBlockParts = propBlock.MakePartSet(partSize) blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} newVss = make([]*validatorStub, nVals+3) @@ -594,7 +584,7 @@ func TestHandshakeReplayNone(t *testing.T) { // Test mockProxyApp should not panic when app return ABCIResponses with some empty ResponseDeliverTx func TestMockProxyApp(t *testing.T) { - sim.CleanupFunc() //clean the test env created in TestSimulateValidatorsChange + sim.CleanupFunc() // clean the test env created in TestSimulateValidatorsChange logger := log.TestingLogger() var validTxs, invalidTxs = 0, 0 txIndex := 0 @@ -676,7 +666,7 @@ func testHandshakeReplay(t *testing.T, config *cfg.Config, nBlocks int, mode uin chain = append([]*types.Block{}, sim.Chain...) // copy chain commits = sim.Commits store = newMockBlockStore(config, genesisState.ConsensusParams) - } else { //test single node + } else { // test single node testConfig := ResetConfig(fmt.Sprintf("%s_%v_s", t.Name(), mode)) defer os.RemoveAll(testConfig.RootDir) walBody, err := WALWithNBlocks(t, numBlocks) @@ -805,14 +795,14 @@ func buildAppStateFromChain(proxyApp proxy.AppConns, stateStore sm.Store, } defer proxyApp.Stop() //nolint:errcheck // ignore - state.Version.Consensus.App = kvstore.ProtocolVersion //simulate handshake, receive app version + state.Version.Consensus.App = kvstore.ProtocolVersion // simulate handshake, receive app version validators := types.TM2PB.ValidatorUpdates(state.Validators) if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ Validators: validators, }); err != nil { panic(err) } - if err := stateStore.Save(state); err != nil { //save height 1's validatorsInfo + if err := stateStore.Save(state); err != nil { // save height 1's validatorsInfo panic(err) } switch mode { @@ -853,16 +843,16 @@ func buildTMStateFromChain( if err := proxyApp.Start(); err != nil { panic(err) } - defer proxyApp.Stop() //nolint:errcheck //ignore + defer proxyApp.Stop() //nolint:errcheck - state.Version.Consensus.App = kvstore.ProtocolVersion //simulate handshake, receive app version + state.Version.Consensus.App = kvstore.ProtocolVersion // simulate handshake, receive app version validators := types.TM2PB.ValidatorUpdates(state.Validators) if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ Validators: validators, }); err != nil { panic(err) } - if err := stateStore.Save(state); err != nil { //save height 1's validatorsInfo + if err := stateStore.Save(state); err != nil { // save height 1's validatorsInfo panic(err) } switch mode { diff --git a/consensus/state.go b/consensus/state.go index d59a4f81d..bed855e6c 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -520,7 +520,7 @@ func (cs *State) updateRoundStep(round int32, step cstypes.RoundStepType) { // enterNewRound(height, 0) at cs.StartTime. func (cs *State) scheduleRound0(rs *cstypes.RoundState) { - //cs.Logger.Info("scheduleRound0", "now", tmtime.Now(), "startTime", cs.StartTime) + // cs.Logger.Info("scheduleRound0", "now", tmtime.Now(), "startTime", cs.StartTime) sleepDuration := rs.StartTime.Sub(tmtime.Now()) cs.scheduleTimeout(sleepDuration, rs.Height, 0, cstypes.RoundStepNewHeight) } @@ -2137,9 +2137,9 @@ func (cs *State) signAddVote(msgType tmproto.SignedMsgType, hash []byte, header cs.Logger.Info("Signed and pushed vote", "height", cs.Height, "round", cs.Round, "vote", vote, "err", err) return vote } - //if !cs.replayMode { + // if !cs.replayMode { cs.Logger.Error("Error signing vote", "height", cs.Height, "round", cs.Round, "vote", vote, "err", err) - //} + // } return nil } diff --git a/consensus/state_test.go b/consensus/state_test.go index 85358ae50..fa2aafb56 100644 --- a/consensus/state_test.go +++ b/consensus/state_test.go @@ -191,7 +191,7 @@ func TestStateBadProposal(t *testing.T) { proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _ := cs1.createProposalBlock() //changeProposer(t, cs1, vs2) + propBlock, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) // make the second validator the proposer by incrementing round round++ @@ -380,7 +380,7 @@ func TestStateFullRound2(t *testing.T) { signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propPartSetHeader, vs2) ensurePrevote(voteCh, height, round) // prevote - ensurePrecommit(voteCh, height, round) //precommit + ensurePrecommit(voteCh, height, round) // precommit // the proposed block should now be locked and our precommit added validatePrecommit(t, cs1, 0, 0, vss[0], propBlockHash, propBlockHash) diff --git a/consensus/wal.go b/consensus/wal.go index abc2edf64..80f5e6b07 100644 --- a/consensus/wal.go +++ b/consensus/wal.go @@ -208,7 +208,7 @@ func (wal *BaseWAL) WriteSync(msg WALMessage) error { } if err := wal.FlushAndSync(); err != nil { - wal.Logger.Error(`WriteSync failed to flush consensus wal. + wal.Logger.Error(`WriteSync failed to flush consensus wal. WARNING: may result in creating alternative proposals / votes for the current height iff the node restarted`, "err", err) return err @@ -282,8 +282,6 @@ func (wal *BaseWAL) SearchForEndHeight( return nil, false, nil } -/////////////////////////////////////////////////////////////////////////////// - // A WALEncoder writes custom-encoded WAL messages to an output stream. // // Format: 4 bytes CRC sum + 4 bytes length + arbitrary-length value @@ -330,8 +328,6 @@ func (enc *WALEncoder) Encode(v *TimedWALMessage) error { return err } -/////////////////////////////////////////////////////////////////////////////// - // IsDataCorruptionError returns true if data has been corrupted inside WAL. func IsDataCorruptionError(err error) bool { _, ok := err.(DataCorruptionError) diff --git a/consensus/wal_generator.go b/consensus/wal_generator.go index f141c9201..1c449717b 100644 --- a/consensus/wal_generator.go +++ b/consensus/wal_generator.go @@ -35,7 +35,6 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { logger := log.TestingLogger().With("wal_generator", "wal_generator") logger.Info("generating WAL (last height msg excluded)", "numBlocks", numBlocks) - ///////////////////////////////////////////////////////////////////////////// // COPY PASTE FROM node.go WITH A FEW MODIFICATIONS // NOTE: we can't import node package because of circular dependency. // NOTE: we don't do handshake so need to set state.Version.Consensus.App directly. @@ -91,7 +90,6 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { consensusState.SetPrivValidator(privValidator) } // END OF COPY PASTE - ///////////////////////////////////////////////////////////////////////////// // set consensus wal to buffered WAL, which will write all incoming msgs to buffer numBlocksWritten := make(chan struct{}) @@ -121,7 +119,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { } } -//WALWithNBlocks returns a WAL content with numBlocks. +// WALWithNBlocks returns a WAL content with numBlocks. func WALWithNBlocks(t *testing.T, numBlocks int) (data []byte, err error) { var b bytes.Buffer wr := bufio.NewWriter(&b) diff --git a/consensus/wal_test.go b/consensus/wal_test.go index ae0c7140f..4ee813609 100644 --- a/consensus/wal_test.go +++ b/consensus/wal_test.go @@ -60,7 +60,7 @@ func TestWALTruncate(t *testing.T) { err = WALGenerateNBlocks(t, wal.Group(), 60) require.NoError(t, err) - time.Sleep(1 * time.Millisecond) //wait groupCheckDuration, make sure RotateFile run + time.Sleep(1 * time.Millisecond) // wait groupCheckDuration, make sure RotateFile run if err := wal.FlushAndSync(); err != nil { t.Error(err) diff --git a/libs/bytes/bytes.go b/libs/bytes/bytes.go index d7682437b..809049e84 100644 --- a/libs/bytes/bytes.go +++ b/libs/bytes/bytes.go @@ -25,7 +25,7 @@ func (bz HexBytes) MarshalJSON() ([]byte, error) { s := strings.ToUpper(hex.EncodeToString(bz)) jbz := make([]byte, len(s)+2) jbz[0] = '"' - copy(jbz[1:], []byte(s)) + copy(jbz[1:], s) jbz[len(jbz)-1] = '"' return jbz, nil } diff --git a/libs/clist/clist_test.go b/libs/clist/clist_test.go index 14b7e37c0..d10a1e5ae 100644 --- a/libs/clist/clist_test.go +++ b/libs/clist/clist_test.go @@ -33,21 +33,21 @@ func TestSmall(t *testing.T) { t.Error("Expected len 3, got ", l.Len()) } - //fmt.Printf("%p %v\n", el1, el1) - //fmt.Printf("%p %v\n", el2, el2) - //fmt.Printf("%p %v\n", el3, el3) + // fmt.Printf("%p %v\n", el1, el1) + // fmt.Printf("%p %v\n", el2, el2) + // fmt.Printf("%p %v\n", el3, el3) r1 := l.Remove(el1) - //fmt.Printf("%p %v\n", el1, el1) - //fmt.Printf("%p %v\n", el2, el2) - //fmt.Printf("%p %v\n", el3, el3) + // fmt.Printf("%p %v\n", el1, el1) + // fmt.Printf("%p %v\n", el2, el2) + // fmt.Printf("%p %v\n", el3, el3) r2 := l.Remove(el2) - //fmt.Printf("%p %v\n", el1, el1) - //fmt.Printf("%p %v\n", el2, el2) - //fmt.Printf("%p %v\n", el3, el3) + // fmt.Printf("%p %v\n", el1, el1) + // fmt.Printf("%p %v\n", el2, el2) + // fmt.Printf("%p %v\n", el3, el3) r3 := l.Remove(el3) @@ -97,10 +97,10 @@ func _TestGCFifo(t *testing.T) { for el := l.Front(); el != nil; { l.Remove(el) - //oldEl := el + // oldEl := el el = el.Next() - //oldEl.DetachPrev() - //oldEl.DetachNext() + // oldEl.DetachPrev() + // oldEl.DetachNext() } runtime.GC() @@ -211,7 +211,7 @@ func TestScanRightDeleteRandom(t *testing.T) { // Remove it l.Remove(rmEl) - //fmt.Print(".") + // fmt.Print(".") // Insert a new element newEl := l.PushBack(-1*i - 1) diff --git a/libs/cmap/cmap_test.go b/libs/cmap/cmap_test.go index 669e50882..bab78da96 100644 --- a/libs/cmap/cmap_test.go +++ b/libs/cmap/cmap_test.go @@ -22,7 +22,7 @@ func TestIterateKeysWithValues(t *testing.T) { // Iterating Keys, checking for matching Value for _, key := range cmap.Keys() { - val := strings.Replace(key, "key", "value", -1) + val := strings.ReplaceAll(key, "key", "value") assert.Equal(t, val, cmap.Get(key)) } diff --git a/libs/fail/fail.go b/libs/fail/fail.go index 03f4feda0..38cec9a29 100644 --- a/libs/fail/fail.go +++ b/libs/fail/fail.go @@ -23,7 +23,7 @@ func envSet() int { } // Fail when FAIL_TEST_INDEX == callIndex -var callIndex int //indexes Fail calls +var callIndex int // indexes Fail calls func Fail() { callIndexToFail := envSet() diff --git a/libs/log/tracing_logger_test.go b/libs/log/tracing_logger_test.go index 354476755..6d6edc5ca 100644 --- a/libs/log/tracing_logger_test.go +++ b/libs/log/tracing_logger_test.go @@ -22,16 +22,16 @@ func TestTracingLogger(t *testing.T) { err2 := errors.New("it does not matter how slowly you go, so long as you do not stop") logger1.With("err1", err1).Info("foo", "err2", err2) - want := strings.Replace( - strings.Replace( + want := strings.ReplaceAll( + strings.ReplaceAll( `{"_msg":"foo","err1":"`+ fmt.Sprintf("%+v", err1)+ `","err2":"`+ fmt.Sprintf("%+v", err2)+ `","level":"info"}`, - "\t", "", -1, - ), "\n", "", -1) - have := strings.Replace(strings.Replace(strings.TrimSpace(buf.String()), "\\n", "", -1), "\\t", "", -1) + "\t", "", + ), "\n", "") + have := strings.ReplaceAll(strings.ReplaceAll(strings.TrimSpace(buf.String()), "\\n", ""), "\\t", "") if want != have { t.Errorf("\nwant '%s'\nhave '%s'", want, have) } diff --git a/libs/math/fraction.go b/libs/math/fraction.go index 4883c0d3d..399bc1c18 100644 --- a/libs/math/fraction.go +++ b/libs/math/fraction.go @@ -25,7 +25,7 @@ func (fr Fraction) String() string { // to the equivalent fraction else returns an error. The format of the string must be // one number followed by a slash (/) and then the other number. func ParseFraction(f string) (Fraction, error) { - o := strings.SplitN(f, "/", -1) + o := strings.Split(f, "/") if len(o) != 2 { return Fraction{}, errors.New("incorrect formating: should be like \"1/3\"") } diff --git a/libs/protoio/io_test.go b/libs/protoio/io_test.go index 5ec5627d2..f4556b31f 100644 --- a/libs/protoio/io_test.go +++ b/libs/protoio/io_test.go @@ -50,11 +50,11 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error { r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := range msgs { msgs[i] = test.NewPopulatedNinOptNative(r, true) - //issue 31 + // issue 31 if i == 5 { msgs[i] = &test.NinOptNative{} } - //issue 31 + // issue 31 if i == 999 { msgs[i] = &test.NinOptNative{} } @@ -133,7 +133,7 @@ func TestVarintNoClose(t *testing.T) { } } -//issue 32 +// issue 32 func TestVarintMaxSize(t *testing.T) { buf := newBuffer() writer := protoio.NewDelimitedWriter(buf) diff --git a/libs/pubsub/pubsub_test.go b/libs/pubsub/pubsub_test.go index 10aaaf05f..8482a13fa 100644 --- a/libs/pubsub/pubsub_test.go +++ b/libs/pubsub/pubsub_test.go @@ -488,9 +488,7 @@ func benchmarkNClientsOneQuery(n int, b *testing.B) { } } -/////////////////////////////////////////////////////////////////////////////// -/// HELPERS -/////////////////////////////////////////////////////////////////////////////// +// HELPERS func assertReceive(t *testing.T, expected interface{}, ch <-chan pubsub.Message, msgAndArgs ...interface{}) { select { diff --git a/node/id.go b/node/id.go index 18e6aeb5d..ffa162f81 100644 --- a/node/id.go +++ b/node/id.go @@ -30,6 +30,6 @@ type SignedNodeGreeting struct { } func (pnid *PrivNodeID) SignGreeting() *SignedNodeGreeting { - //greeting := NodeGreeting{} + // greeting := NodeGreeting{} return nil } diff --git a/p2p/conn/secret_connection_test.go b/p2p/conn/secret_connection_test.go index 70793b8a0..d4997d81c 100644 --- a/p2p/conn/secret_connection_test.go +++ b/p2p/conn/secret_connection_test.go @@ -380,7 +380,6 @@ func makeSecretConnPair(tb testing.TB) (fooSecConn, barSecConn *SecretConnection return fooSecConn, barSecConn } -/////////////////////////////////////////////////////////////////////////////// // Benchmarks func BenchmarkWriteSecretConnection(b *testing.B) { @@ -428,7 +427,7 @@ func BenchmarkWriteSecretConnection(b *testing.B) { if err := fooSecConn.Close(); err != nil { b.Error(err) } - //barSecConn.Close() race condition + // barSecConn.Close() race condition } func BenchmarkReadSecretConnection(b *testing.B) { diff --git a/p2p/switch_test.go b/p2p/switch_test.go index 4601c2839..538ccfcc3 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -75,7 +75,7 @@ func (tr *TestReactor) Receive(chID byte, peer Peer, msgBytes []byte) { if tr.logMessages { tr.mtx.Lock() defer tr.mtx.Unlock() - //fmt.Printf("Received: %X, %X\n", chID, msgBytes) + // fmt.Printf("Received: %X, %X\n", chID, msgBytes) tr.msgsReceived[chID] = append(tr.msgsReceived[chID], PeerMessage{peer.ID(), msgBytes, tr.msgsCounter}) tr.msgsCounter++ } diff --git a/p2p/upnp/upnp.go b/p2p/upnp/upnp.go index 9f69753d0..c00530aca 100644 --- a/p2p/upnp/upnp.go +++ b/p2p/upnp/upnp.go @@ -269,7 +269,7 @@ func soapRequest(url, function, message, domain string) (r *http.Response, err e } req.Header.Set("Content-Type", "text/xml ; charset=\"utf-8\"") req.Header.Set("User-Agent", "Darwin/10.0.0, UPnP/1.0, MiniUPnPc/1.3") - //req.Header.Set("Transfer-Encoding", "chunked") + // req.Header.Set("Transfer-Encoding", "chunked") req.Header.Set("SOAPAction", "\"urn:"+domain+":service:WANIPConnection:1#"+function+"\"") req.Header.Set("Connection", "Close") req.Header.Set("Cache-Control", "no-cache") diff --git a/privval/signer_listener_endpoint_test.go b/privval/signer_listener_endpoint_test.go index 99d734ae3..02b19eff3 100644 --- a/privval/signer_listener_endpoint_test.go +++ b/privval/signer_listener_endpoint_test.go @@ -145,8 +145,6 @@ func TestRetryConnToRemoteSigner(t *testing.T) { } } -/////////////////////////////////// - func newSignerListenerEndpoint(logger log.Logger, addr string, timeoutReadWrite time.Duration) *SignerListenerEndpoint { proto, address := tmnet.ProtocolAndAddress(addr) diff --git a/proxy/app_conn_test.go b/proxy/app_conn_test.go index 022bd8997..683fe47e0 100644 --- a/proxy/app_conn_test.go +++ b/proxy/app_conn_test.go @@ -123,7 +123,7 @@ func BenchmarkEcho(b *testing.B) { b.StopTimer() // info := proxy.InfoSync(types.RequestInfo{""}) - //b.Log("N: ", b.N, info) + // b.Log("N: ", b.N, info) } func TestInfo(t *testing.T) { diff --git a/rpc/client/examples_test.go b/rpc/client/examples_test.go index dc2792ea2..474aba1b6 100644 --- a/rpc/client/examples_test.go +++ b/rpc/client/examples_test.go @@ -22,7 +22,7 @@ func ExampleHTTP_simple() { rpcAddr := rpctest.GetConfig().RPC.ListenAddress c, err := rpchttp.New(rpcAddr, "/websocket") if err != nil { - log.Fatal(err) + log.Fatal(err) //nolint:gocritic } // Create a transaction @@ -69,7 +69,6 @@ func ExampleHTTP_batching() { // Start a tendermint node (and kvstore) in the background to test against app := kvstore.NewApplication() node := rpctest.StartTendermint(app, rpctest.SuppressStdout, rpctest.RecreateConfig) - defer rpctest.StopTendermint(node) // Create our RPC client rpcAddr := rpctest.GetConfig().RPC.ListenAddress @@ -78,6 +77,8 @@ func ExampleHTTP_batching() { log.Fatal(err) } + defer rpctest.StopTendermint(node) + // Create our two transactions k1 := []byte("firstName") v1 := []byte("satoshi") @@ -97,7 +98,7 @@ func ExampleHTTP_batching() { // Broadcast the transaction and wait for it to commit (rather use // c.BroadcastTxSync though in production). if _, err := batch.BroadcastTxCommit(context.Background(), tx); err != nil { - log.Fatal(err) + log.Fatal(err) //nolint:gocritic } } diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index 85b9c501d..49f26b85f 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -82,7 +82,7 @@ func TestCustomHTTPClient(t *testing.T) { func TestCorsEnabled(t *testing.T) { origin := rpctest.GetConfig().RPC.CORSAllowedOrigins[0] - remote := strings.Replace(rpctest.GetConfig().RPC.ListenAddress, "tcp", "http", -1) + remote := strings.ReplaceAll(rpctest.GetConfig().RPC.ListenAddress, "tcp", "http") req, err := http.NewRequest("GET", remote, nil) require.Nil(t, err, "%+v", err) diff --git a/rpc/jsonrpc/client/http_json_client.go b/rpc/jsonrpc/client/http_json_client.go index 1cd704d7b..c6e1af035 100644 --- a/rpc/jsonrpc/client/http_json_client.go +++ b/rpc/jsonrpc/client/http_json_client.go @@ -66,7 +66,7 @@ func (u parsedURL) GetHostWithPath() string { // Get a trimmed address - useful for WS connections func (u parsedURL) GetTrimmedHostWithPath() string { // replace / with . for http requests (kvstore domain) - return strings.Replace(u.GetHostWithPath(), "/", ".", -1) + return strings.ReplaceAll(u.GetHostWithPath(), "/", ".") } // Get a trimmed address with protocol - useful as address in RPC connections diff --git a/rpc/jsonrpc/client/ws_client.go b/rpc/jsonrpc/client/ws_client.go index 832947909..1c7ade657 100644 --- a/rpc/jsonrpc/client/ws_client.go +++ b/rpc/jsonrpc/client/ws_client.go @@ -248,7 +248,6 @@ func (c *WSClient) CallWithArrayParams(ctx context.Context, method string, param return c.Send(ctx, request) } -/////////////////////////////////////////////////////////////////////////////// // Private methods func (c *WSClient) nextRequestID() types.JSONRPCIntID { @@ -521,7 +520,6 @@ func (c *WSClient) readRoutine() { } } -/////////////////////////////////////////////////////////////////////////////// // Predefined methods // Subscribe to a query. Note the server must have a "subscribe" route diff --git a/rpc/jsonrpc/jsonrpc_test.go b/rpc/jsonrpc/jsonrpc_test.go index 24269df8e..ec12f85d7 100644 --- a/rpc/jsonrpc/jsonrpc_test.go +++ b/rpc/jsonrpc/jsonrpc_test.go @@ -404,5 +404,5 @@ func randBytes(t *testing.T) []byte { buf := make([]byte, n) _, err := crand.Read(buf) require.Nil(t, err) - return bytes.Replace(buf, []byte("="), []byte{100}, -1) + return bytes.ReplaceAll(buf, []byte("="), []byte{100}) } diff --git a/rpc/jsonrpc/server/http_json_handler.go b/rpc/jsonrpc/server/http_json_handler.go index ffc244580..ffe9d133b 100644 --- a/rpc/jsonrpc/server/http_json_handler.go +++ b/rpc/jsonrpc/server/http_json_handler.go @@ -14,9 +14,7 @@ import ( types "github.com/tendermint/tendermint/rpc/jsonrpc/types" ) -/////////////////////////////////////////////////////////////////////////////// // HTTP + JSON handler -/////////////////////////////////////////////////////////////////////////////// // jsonrpc calls grab the given method's function info and runs reflect.Call func makeJSONRPCHandler(funcMap map[string]*RPCFunc, logger log.Logger) http.HandlerFunc { diff --git a/rpc/jsonrpc/server/http_uri_handler.go b/rpc/jsonrpc/server/http_uri_handler.go index 5efe0fbbe..3e6250183 100644 --- a/rpc/jsonrpc/server/http_uri_handler.go +++ b/rpc/jsonrpc/server/http_uri_handler.go @@ -13,9 +13,7 @@ import ( types "github.com/tendermint/tendermint/rpc/jsonrpc/types" ) -/////////////////////////////////////////////////////////////////////////////// // HTTP + URI handler -/////////////////////////////////////////////////////////////////////////////// var reInt = regexp.MustCompile(`^-?[0-9]+$`) diff --git a/rpc/jsonrpc/server/rpc_func.go b/rpc/jsonrpc/server/rpc_func.go index eed1fea8f..e5855c314 100644 --- a/rpc/jsonrpc/server/rpc_func.go +++ b/rpc/jsonrpc/server/rpc_func.go @@ -23,9 +23,7 @@ func RegisterRPCFuncs(mux *http.ServeMux, funcMap map[string]*RPCFunc, logger lo mux.HandleFunc("/", handleInvalidJSONRPCPaths(makeJSONRPCHandler(funcMap, logger))) } -/////////////////////////////////////////////////////////////////////////////// // Function introspection -/////////////////////////////////////////////////////////////////////////////// // RPCFunc contains the introspected type information for a function type RPCFunc struct { diff --git a/rpc/jsonrpc/server/ws_handler.go b/rpc/jsonrpc/server/ws_handler.go index 7faf76a68..e4e5d7504 100644 --- a/rpc/jsonrpc/server/ws_handler.go +++ b/rpc/jsonrpc/server/ws_handler.go @@ -17,9 +17,7 @@ import ( types "github.com/tendermint/tendermint/rpc/jsonrpc/types" ) -/////////////////////////////////////////////////////////////////////////////// // WebSocket handler -/////////////////////////////////////////////////////////////////////////////// const ( defaultWSWriteChanCapacity = 100 @@ -100,9 +98,7 @@ func (wm *WebsocketManager) WebsocketHandler(w http.ResponseWriter, r *http.Requ } } -/////////////////////////////////////////////////////////////////////////////// // WebSocket connection -/////////////////////////////////////////////////////////////////////////////// // A single websocket connection contains listener id, underlying ws // connection, and the event switch for subscribing to events. diff --git a/rpc/test/helpers.go b/rpc/test/helpers.go index 5e212ec42..19099d5e5 100644 --- a/rpc/test/helpers.go +++ b/rpc/test/helpers.go @@ -72,7 +72,7 @@ func makePathname() string { } // fmt.Println(p) sep := string(filepath.Separator) - return strings.Replace(p, sep, "_", -1) + return strings.ReplaceAll(p, sep, "_") } func randPort() int { diff --git a/scripts/wal2json/main.go b/scripts/wal2json/main.go index fa4f4e25d..6fa890522 100644 --- a/scripts/wal2json/main.go +++ b/scripts/wal2json/main.go @@ -46,14 +46,17 @@ func main() { if err == nil { _, err = os.Stdout.Write([]byte("\n")) } + if err == nil { if endMsg, ok := msg.Msg.(cs.EndHeightMessage); ok { _, err = os.Stdout.Write([]byte(fmt.Sprintf("ENDHEIGHT %d\n", endMsg.Height))) } } + if err != nil { fmt.Println("Failed to write message", err) - os.Exit(1) + os.Exit(1) //nolint:gocritic } + } } diff --git a/state/state.go b/state/state.go index 9c9bb6f98..d9da840ca 100644 --- a/state/state.go +++ b/state/state.go @@ -131,7 +131,7 @@ func (state State) IsEmpty() bool { return state.Validators == nil // XXX can't compare to Empty } -//ToProto takes the local state type and returns the equivalent proto type +// ToProto takes the local state type and returns the equivalent proto type func (state *State) ToProto() (*tmstate.State, error) { if state == nil { return nil, errors.New("state is nil") diff --git a/state/state_test.go b/state/state_test.go index 778bae196..1632f4304 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -59,7 +59,7 @@ func TestStateCopy(t *testing.T) { %v`, state)) } -//TestMakeGenesisStateNilValidators tests state's consistency when genesis file's validators field is nil. +// TestMakeGenesisStateNilValidators tests state's consistency when genesis file's validators field is nil. func TestMakeGenesisStateNilValidators(t *testing.T) { doc := types.GenesisDoc{ ChainID: "dummy", diff --git a/state/store.go b/state/store.go index 0b9cc6890..5bd2d9fc7 100644 --- a/state/store.go +++ b/state/store.go @@ -70,7 +70,7 @@ type Store interface { PruneStates(int64, int64) error } -//dbStore wraps a db (github.com/tendermint/tm-db) +// dbStore wraps a db (github.com/tendermint/tm-db) type dbStore struct { db dbm.DB } @@ -390,7 +390,7 @@ func (store dbStore) LoadABCIResponses(height int64) (*tmstate.ABCIResponses, er // Exposed for testing. func (store dbStore) SaveABCIResponses(height int64, abciResponses *tmstate.ABCIResponses) error { var dtxs []*abci.ResponseDeliverTx - //strip nil values, + // strip nil values, for _, tx := range abciResponses.DeliverTxs { if tx != nil { dtxs = append(dtxs, tx) diff --git a/state/txindex/kv/kv.go b/state/txindex/kv/kv.go index 11bbebbc9..b056e9dd4 100644 --- a/state/txindex/kv/kv.go +++ b/state/txindex/kv/kv.go @@ -613,7 +613,6 @@ LOOP: return filteredHashes } -/////////////////////////////////////////////////////////////////////////////// // Keys func isTagKey(key []byte) bool { diff --git a/store/store.go b/store/store.go index 6674e4b52..9ae4d555d 100644 --- a/store/store.go +++ b/store/store.go @@ -488,7 +488,7 @@ func LoadBlockStoreState(db dbm.DB) tmstore.BlockStoreState { return bsj } -//mustEncode proto encodes a proto.message and panics if fails +// mustEncode proto encodes a proto.message and panics if fails func mustEncode(pb proto.Message) []byte { bz, err := proto.Marshal(pb) if err != nil { diff --git a/types/events.go b/types/events.go index 5ed2d6dfe..38b356983 100644 --- a/types/events.go +++ b/types/events.go @@ -38,9 +38,7 @@ const ( EventVote = "Vote" ) -/////////////////////////////////////////////////////////////////////////////// // ENCODING / DECODING -/////////////////////////////////////////////////////////////////////////////// // TMEventData implements events.EventData. type TMEventData interface { @@ -127,9 +125,7 @@ type EventDataValidatorSetUpdates struct { ValidatorUpdates []*Validator `json:"validator_updates"` } -/////////////////////////////////////////////////////////////////////////////// // PUBSUB -/////////////////////////////////////////////////////////////////////////////// const ( // EventTypeKey is a reserved composite key for event name. diff --git a/types/part_set_test.go b/types/part_set_test.go index e7347e2f1..c6ea0f452 100644 --- a/types/part_set_test.go +++ b/types/part_set_test.go @@ -35,7 +35,7 @@ func TestBasicPartSet(t *testing.T) { assert.True(t, partSet2.HasHeader(partSet.Header())) for i := 0; i < int(partSet.Total()); i++ { part := partSet.GetPart(i) - //t.Logf("\n%v", part) + // t.Logf("\n%v", part) added, err := partSet2.AddPart(part) if !added || err != nil { t.Errorf("failed to add part %v, error: %v", i, err) diff --git a/types/priv_validator.go b/types/priv_validator.go index 394123164..49211773a 100644 --- a/types/priv_validator.go +++ b/types/priv_validator.go @@ -39,9 +39,7 @@ func (pvs PrivValidatorsByAddress) Less(i, j int) bool { } func (pvs PrivValidatorsByAddress) Swap(i, j int) { - it := pvs[i] - pvs[i] = pvs[j] - pvs[j] = it + pvs[i], pvs[j] = pvs[j], pvs[i] } //---------------------------------------- diff --git a/types/validator_set.go b/types/validator_set.go index cdd748476..cc1a452a1 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -708,9 +708,7 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, return nil } -/////////////////////////////////////////////////////////////////////////////// // LIGHT CLIENT VERIFICATION METHODS -/////////////////////////////////////////////////////////////////////////////// // VerifyCommitLight verifies +2/3 of the set had signed the given commit. // @@ -1026,7 +1024,6 @@ func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []Pr return NewValidatorSet(valz), privValidators } -/////////////////////////////////////////////////////////////////////////////// // safe addition/subtraction/multiplication func safeAdd(a, b int64) (int64, bool) { diff --git a/types/validator_set_test.go b/types/validator_set_test.go index 9ce5b6025..84fdcdf48 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -1658,9 +1658,7 @@ func (valz validatorsByPriority) Less(i, j int) bool { } func (valz validatorsByPriority) Swap(i, j int) { - it := valz[i] - valz[i] = valz[j] - valz[j] = it + valz[i], valz[j] = valz[j], valz[i] } //------------------------------------- @@ -1679,9 +1677,7 @@ func (tvals testValsByVotingPower) Less(i, j int) bool { } func (tvals testValsByVotingPower) Swap(i, j int) { - it := tvals[i] - tvals[i] = tvals[j] - tvals[j] = it + tvals[i], tvals[j] = tvals[j], tvals[i] } //------------------------------------- diff --git a/types/vote.go b/types/vote.go index 29cfdd051..7b841c28a 100644 --- a/types/vote.go +++ b/types/vote.go @@ -220,7 +220,7 @@ func (vote *Vote) ToProto() *tmproto.Vote { } } -//FromProto converts a proto generetad type to a handwritten type +// FromProto converts a proto generetad type to a handwritten type // return type, nil if everything converts safely, otherwise nil, error func VoteFromProto(pv *tmproto.Vote) (*Vote, error) { if pv == nil {