les: changed if-else blocks to conform with golint (#16658)

This commit is contained in:
GagziW 2018-05-03 01:35:06 -07:00 committed by Péter Szilágyi
parent f2447bd4c3
commit 7c02933275
4 changed files with 14 additions and 20 deletions

View File

@ -97,9 +97,8 @@ func (p *testDistPeer) waitBefore(cost uint64) (time.Duration, float64) {
p.lock.RUnlock() p.lock.RUnlock()
if sumCost < testDistBufLimit { if sumCost < testDistBufLimit {
return 0, float64(testDistBufLimit-sumCost) / float64(testDistBufLimit) return 0, float64(testDistBufLimit-sumCost) / float64(testDistBufLimit)
} else {
return time.Duration(sumCost - testDistBufLimit), 0
} }
return time.Duration(sumCost - testDistBufLimit), 0
} }
func (p *testDistPeer) canQueue() bool { func (p *testDistPeer) canQueue() bool {

View File

@ -160,9 +160,8 @@ func (a *announceData) checkSignature(pubKey *ecdsa.PublicKey) error {
pbytes := elliptic.Marshal(pubKey.Curve, pubKey.X, pubKey.Y) pbytes := elliptic.Marshal(pubKey.Curve, pubKey.X, pubKey.Y)
if bytes.Equal(pbytes, recPubkey) { if bytes.Equal(pbytes, recPubkey) {
return nil return nil
} else {
return errors.New("Wrong signature")
} }
return errors.New("Wrong signature")
} }
type blockInfo struct { type blockInfo struct {

View File

@ -118,7 +118,7 @@ func (n *wrsNode) insert(item wrsItem, weight int64) int {
if n.level == 0 { if n.level == 0 {
n.items[branch] = item n.items[branch] = item
return branch return branch
} else { }
var subNode *wrsNode var subNode *wrsNode
if n.items[branch] == nil { if n.items[branch] == nil {
subNode = &wrsNode{maxItems: n.maxItems / wrsBranches, level: n.level - 1} subNode = &wrsNode{maxItems: n.maxItems / wrsBranches, level: n.level - 1}
@ -128,7 +128,6 @@ func (n *wrsNode) insert(item wrsItem, weight int64) int {
} }
subIdx := subNode.insert(item, weight) subIdx := subNode.insert(item, weight)
return subNode.maxItems*branch + subIdx return subNode.maxItems*branch + subIdx
}
} }
// setWeight updates the weight of a certain item (which should exist) and returns // setWeight updates the weight of a certain item (which should exist) and returns
@ -162,12 +161,10 @@ func (n *wrsNode) choose(val int64) (wrsItem, int64) {
if val < w { if val < w {
if n.level == 0 { if n.level == 0 {
return n.items[i].(wrsItem), n.weights[i] return n.items[i].(wrsItem), n.weights[i]
} else { }
return n.items[i].(*wrsNode).choose(val) return n.items[i].(*wrsNode).choose(val)
} }
} else {
val -= w val -= w
} }
}
panic(nil) panic(nil)
} }

View File

@ -601,9 +601,8 @@ func (e *discoveredEntry) Weight() int64 {
t := time.Duration(mclock.Now() - e.lastDiscovered) t := time.Duration(mclock.Now() - e.lastDiscovered)
if t <= discoverExpireStart { if t <= discoverExpireStart {
return 1000000000 return 1000000000
} else {
return int64(1000000000 * math.Exp(-float64(t-discoverExpireStart)/float64(discoverExpireConst)))
} }
return int64(1000000000 * math.Exp(-float64(t-discoverExpireStart)/float64(discoverExpireConst)))
} }
// knownEntry implements wrsItem // knownEntry implements wrsItem