Skip to content

Commit 754dd9a

Browse files
GagziWkimmyeonghun
authored andcommitted
les: changed if-else blocks to conform with golint (ethereum#16658)
1 parent 1cfa09f commit 754dd9a

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

les/distributor_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ func (p *testDistPeer) waitBefore(cost uint64) (time.Duration, float64) {
9797
p.lock.RUnlock()
9898
if sumCost < testDistBufLimit {
9999
return 0, float64(testDistBufLimit-sumCost) / float64(testDistBufLimit)
100-
} else {
101-
return time.Duration(sumCost - testDistBufLimit), 0
102100
}
101+
return time.Duration(sumCost - testDistBufLimit), 0
103102
}
104103

105104
func (p *testDistPeer) canQueue() bool {

les/protocol.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ func (a *announceData) checkSignature(pubKey *ecdsa.PublicKey) error {
160160
pbytes := elliptic.Marshal(pubKey.Curve, pubKey.X, pubKey.Y)
161161
if bytes.Equal(pbytes, recPubkey) {
162162
return nil
163-
} else {
164-
return errors.New("Wrong signature")
165163
}
164+
return errors.New("Wrong signature")
166165
}
167166

168167
type blockInfo struct {

les/randselect.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,16 @@ func (n *wrsNode) insert(item wrsItem, weight int64) int {
118118
if n.level == 0 {
119119
n.items[branch] = item
120120
return branch
121+
}
122+
var subNode *wrsNode
123+
if n.items[branch] == nil {
124+
subNode = &wrsNode{maxItems: n.maxItems / wrsBranches, level: n.level - 1}
125+
n.items[branch] = subNode
121126
} else {
122-
var subNode *wrsNode
123-
if n.items[branch] == nil {
124-
subNode = &wrsNode{maxItems: n.maxItems / wrsBranches, level: n.level - 1}
125-
n.items[branch] = subNode
126-
} else {
127-
subNode = n.items[branch].(*wrsNode)
128-
}
129-
subIdx := subNode.insert(item, weight)
130-
return subNode.maxItems*branch + subIdx
127+
subNode = n.items[branch].(*wrsNode)
131128
}
129+
subIdx := subNode.insert(item, weight)
130+
return subNode.maxItems*branch + subIdx
132131
}
133132

134133
// 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) {
162161
if val < w {
163162
if n.level == 0 {
164163
return n.items[i].(wrsItem), n.weights[i]
165-
} else {
166-
return n.items[i].(*wrsNode).choose(val)
167164
}
168-
} else {
169-
val -= w
165+
return n.items[i].(*wrsNode).choose(val)
170166
}
167+
val -= w
171168
}
172169
panic(nil)
173170
}

les/serverpool.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,8 @@ func (e *discoveredEntry) Weight() int64 {
601601
t := time.Duration(mclock.Now() - e.lastDiscovered)
602602
if t <= discoverExpireStart {
603603
return 1000000000
604-
} else {
605-
return int64(1000000000 * math.Exp(-float64(t-discoverExpireStart)/float64(discoverExpireConst)))
606604
}
605+
return int64(1000000000 * math.Exp(-float64(t-discoverExpireStart)/float64(discoverExpireConst)))
607606
}
608607

609608
// knownEntry implements wrsItem

0 commit comments

Comments
 (0)