linting errors: clean it all up

This commit is contained in:
Zach Ramsay 2017-09-21 10:56:42 -04:00 committed by Ethan Buchman
parent b75d4f73e7
commit 8f0237610e
12 changed files with 25 additions and 34 deletions

View File

@ -313,7 +313,7 @@ func (pool *BlockPool) makeNextRequester() {
_, err := request.Start()
if err != nil {
panic(err)
pool.Logger.Error("Error starting block pool", "err", err)
}
}

View File

@ -48,7 +48,7 @@ func resetPrivValidator(cmd *cobra.Command, args []string) {
func ResetAll(dbDir, privValFile string, logger log.Logger) {
resetPrivValidatorLocal(privValFile, logger)
if err := os.RemoveAll(dbDir); err != nil {
panic(err)
logger.Error("Error removing directory", "err", err)
}
logger.Info("Removed all data", "dir", dbDir)
}

View File

@ -13,10 +13,10 @@ import (
func EnsureRoot(rootDir string) {
if err := cmn.EnsureDir(rootDir, 0700); err != nil {
panic(err)
cmn.PanicSanity(err.Error())
}
if err := cmn.EnsureDir(rootDir+"/data", 0700); err != nil {
panic(err)
cmn.PanicSanity(err.Error())
}
configFilePath := path.Join(rootDir, "config.toml")
@ -69,10 +69,10 @@ func ResetTestRoot(testName string) *Config {
}
// Create new dir
if err := cmn.EnsureDir(rootDir, 0700); err != nil {
panic(err)
cmn.PanicSanity(err.Error())
}
if err := cmn.EnsureDir(rootDir+"/data", 0700); err != nil {
panic(err)
cmn.PanicSanity(err.Error())
}
configFilePath := path.Join(rootDir, "config.toml")

View File

@ -97,7 +97,10 @@ func (conR *ConsensusReactor) SwitchToConsensus(state *sm.State, blocksSynced in
// dont bother with the WAL if we fast synced
conR.conS.doWALCatchup = false
}
conR.conS.Start()
_, err := conR.conS.Start()
if err != nil {
conR.Logger.Error("Error starting conR", "err", err)
}
}
// GetChannels implements Reactor

View File

@ -65,11 +65,7 @@ func (cs *ConsensusState) ReplayFile(file string, console bool) error {
}
pb := newPlayback(file, fp, cs, cs.state.Copy())
defer func() {
if err := pb.fp.Close(); err != nil {
return
}
}()
defer pb.fp.Close()
var nextN int // apply N msgs in a row
var msg *TimedWALMessage
@ -227,7 +223,7 @@ func (pb *playback) replayConsoleLoop() int {
if len(tokens) == 1 {
if err := pb.replayReset(1, newStepCh); err != nil {
panic(err)
pb.cs.Logger.Error("Replay reset error", "err", err)
}
} else {
i, err := strconv.Atoi(tokens[1])
@ -237,7 +233,7 @@ func (pb *playback) replayConsoleLoop() int {
fmt.Printf("argument to back must not be larger than the current count (%d)\n", pb.count)
} else {
if err := pb.replayReset(i, newStepCh); err != nil {
panic(err)
pb.cs.Logger.Error("Replay reset error", "err", err)
}
}
}

View File

@ -259,7 +259,7 @@ func (cs *ConsensusState) OnStart() error {
func (cs *ConsensusState) startRoutines(maxSteps int) {
_, err := cs.timeoutTicker.Start()
if err != nil {
panic(err)
cs.Logger.Error("Error starting timeout ticker", "err", err)
}
go cs.receiveRoutine(maxSteps)
}

View File

@ -3,7 +3,6 @@ package mempool
import (
"bytes"
"container/list"
"fmt"
"sync"
"sync/atomic"
"time"
@ -192,11 +191,11 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error) {
// TODO: Notify administrators when WAL fails
_, err := mem.wal.Write([]byte(tx))
if err != nil {
mem.logger.Error(fmt.Sprintf("Error writing to WAL: %v", err))
mem.logger.Error("Error writing to WAL", "err", err)
}
_, err = mem.wal.Write([]byte("\n"))
if err != nil {
mem.logger.Error(fmt.Sprintf("Error writing to WAL: %v", err))
mem.logger.Error("Error writing to WAL", "err", err)
}
}
// END WAL

View File

@ -101,7 +101,7 @@ func Probe(logger log.Logger) (caps UPNPCapabilities, err error) {
logger.Error(cmn.Fmt("Port mapping delete error: %v", err))
}
if err := listener.Close(); err != nil {
panic(err)
logger.Error(cmn.Fmt("Listener closing error: %v", err))
}
}()

View File

@ -353,7 +353,8 @@ func (c *WSClient) writeRoutine() {
defer func() {
ticker.Stop()
if err := c.conn.Close(); err != nil {
// panic(err) FIXME: this panic will trigger in tests
// ignore error; it will trigger in tests
// likely because it's closing and already closed connection
}
c.wg.Done()
}()
@ -404,7 +405,8 @@ func (c *WSClient) writeRoutine() {
func (c *WSClient) readRoutine() {
defer func() {
if err := c.conn.Close(); err != nil {
// panic(err) FIXME: this panic will trigger in tests
// ignore error; it will trigger in tests
// likely because it's closing and already closed connection
}
c.wg.Done()
}()

View File

@ -720,7 +720,7 @@ func (wm *WebsocketManager) WebsocketHandler(w http.ResponseWriter, r *http.Requ
wm.logger.Info("New websocket connection", "remote", con.remoteAddr)
_, err = con.Start() // Blocking
if err != nil {
panic(err)
wm.logger.Error("Error starting connection", "err", err)
}
}

View File

@ -56,10 +56,7 @@ func WriteRPCResponseHTTPError(w http.ResponseWriter, httpCode int, res types.RP
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(httpCode)
_, err = w.Write(jsonBytes)
if err != nil {
// ignore error
}
_, _ = w.Write(jsonBytes) // ignoring error
}
func WriteRPCResponseHTTP(w http.ResponseWriter, res types.RPCResponse) {
@ -69,10 +66,7 @@ func WriteRPCResponseHTTP(w http.ResponseWriter, res types.RPCResponse) {
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
_, err = w.Write(jsonBytes)
if err != nil {
// ignore error
}
_, _ = w.Write(jsonBytes) // ignoring error
}
//-----------------------------------------------------------------------------

View File

@ -34,10 +34,7 @@ func (part *Part) Hash() []byte {
return part.hash
} else {
hasher := ripemd160.New()
_, err := hasher.Write(part.Bytes)
if err != nil {
// ignore error
}
_, _ := hasher.Write(part.Bytes) // ignoring error
part.hash = hasher.Sum(nil)
return part.hash
}