core: apply megacheck vet tool (unused, gosimple, staticcheck)

This commit is contained in:
zramsay
2017-05-29 23:11:40 -04:00
parent c7cd62b449
commit cf31f8d06f
24 changed files with 67 additions and 177 deletions

View File

@ -142,7 +142,7 @@ func (pool *BlockPool) IsCaughtUp() bool {
maxPeerHeight = MaxInt(maxPeerHeight, peer.height)
}
isCaughtUp := (height > 0 || time.Now().Sub(pool.startTime) > 5*time.Second) && (maxPeerHeight == 0 || height >= maxPeerHeight)
isCaughtUp := (height > 0 || time.Since(pool.startTime) > 5*time.Second) && (maxPeerHeight == 0 || height >= maxPeerHeight)
pool.Logger.Info(Fmt("IsCaughtUp: %v", isCaughtUp), "height", height, "maxPeerHeight", maxPeerHeight)
return isCaughtUp
}
@ -212,9 +212,9 @@ func (pool *BlockPool) AddBlock(peerID string, block *types.Block, blockSize int
pool.numPending--
peer := pool.peers[peerID]
peer.decrPending(blockSize)
} else {
// Bad peer?
}
} // else {
// Bad peer?
// }
}
// Sets the peer's alleged blockchain height.
@ -261,7 +261,6 @@ func (pool *BlockPool) pickIncrAvailablePeer(minHeight int) *bpPeer {
if peer.didTimeout {
pool.removePeer(peer.id)
continue
} else {
}
if peer.numPending >= maxPendingRequestsPerPeer {
continue
@ -303,7 +302,8 @@ func (pool *BlockPool) sendTimeout(peerID string) {
pool.timeoutsCh <- peerID
}
func (pool *BlockPool) debug() string {
// unused by tendermint; left for debugging purposes
/*func (pool *BlockPool) debug() string {
pool.mtx.Lock() // Lock
defer pool.mtx.Unlock()
@ -317,7 +317,7 @@ func (pool *BlockPool) debug() string {
}
}
return str
}
}*/
//-------------------------------------
@ -326,7 +326,6 @@ type bpPeer struct {
id string
recvMonitor *flow.Monitor
mtx sync.Mutex
height int
numPending int32
timeout *time.Timer