mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
les: fix lint
This commit is contained in:
parent
c9601ccf37
commit
f1be1bdcc0
6 changed files with 21 additions and 21 deletions
|
|
@ -83,7 +83,7 @@ type (
|
|||
|
||||
// send sends a changed total capacity event to the subscribers
|
||||
func (s tcSubs) send(tc uint64, underrun bool) {
|
||||
for sub, _ := range s {
|
||||
for sub := range s {
|
||||
select {
|
||||
case <-sub.rpcSub.Err():
|
||||
delete(s, sub)
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ func testCapacityAPI(t *testing.T, clientCount int) {
|
|||
|
||||
processedSince := func(start []uint64) []uint64 {
|
||||
res := make([]uint64, len(reqCount))
|
||||
for i, _ := range reqCount {
|
||||
for i := range reqCount {
|
||||
res[i] = atomic.LoadUint64(&reqCount[i])
|
||||
if start != nil {
|
||||
res[i] -= start[i]
|
||||
|
|
@ -197,7 +197,7 @@ func testCapacityAPI(t *testing.T, clientCount int) {
|
|||
setCapacity(ctx, t, serverRpcClient, clients[freeIdx].ID(), freeCap)
|
||||
freeIdx = rand.Intn(len(clients))
|
||||
var sum float64
|
||||
for i, _ := range clients {
|
||||
for i := range clients {
|
||||
if i == freeIdx {
|
||||
weights[i] = 0
|
||||
} else {
|
||||
|
|
@ -220,14 +220,14 @@ func testCapacityAPI(t *testing.T, clientCount int) {
|
|||
}
|
||||
}
|
||||
weights[freeIdx] = float64(freeCap)
|
||||
for i, _ := range clients {
|
||||
for i := range clients {
|
||||
weights[i] /= float64(testCap)
|
||||
}
|
||||
|
||||
time.Sleep(flowcontrol.DecParamDelay)
|
||||
fmt.Println("Starting measurement")
|
||||
fmt.Printf("Relative weights:")
|
||||
for i, _ := range clients {
|
||||
for i := range clients {
|
||||
fmt.Printf(" %f", weights[i])
|
||||
}
|
||||
fmt.Println()
|
||||
|
|
@ -459,7 +459,7 @@ func testSim(t *testing.T, serverCount, clientCount int, serverDir, clientDir []
|
|||
servers := make([]*simulations.Node, serverCount)
|
||||
clients := make([]*simulations.Node, clientCount)
|
||||
|
||||
for i, _ := range clients {
|
||||
for i := range clients {
|
||||
clientconf := adapters.RandomNodeConfig()
|
||||
clientconf.Services = []string{"lesclient"}
|
||||
if len(clientDir) == clientCount {
|
||||
|
|
@ -472,7 +472,7 @@ func testSim(t *testing.T, serverCount, clientCount int, serverDir, clientDir []
|
|||
clients[i] = client
|
||||
}
|
||||
|
||||
for i, _ := range servers {
|
||||
for i := range servers {
|
||||
serverconf := adapters.RandomNodeConfig()
|
||||
serverconf.Services = []string{"lesserver"}
|
||||
if len(serverDir) == serverCount {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func (b *benchmarkBlockHeaders) init(pm *ProtocolManager, count int) error {
|
|||
}
|
||||
if b.byHash {
|
||||
b.hashes = make([]common.Hash, count)
|
||||
for i, _ := range b.hashes {
|
||||
for i := range b.hashes {
|
||||
b.hashes[i] = rawdb.ReadCanonicalHash(pm.chainDb, uint64(b.offset+rand.Int63n(b.randMax)))
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ type benchmarkBodiesOrReceipts struct {
|
|||
func (b *benchmarkBodiesOrReceipts) init(pm *ProtocolManager, count int) error {
|
||||
randMax := pm.blockchain.CurrentHeader().Number.Int64() + 1
|
||||
b.hashes = make([]common.Hash, count)
|
||||
for i, _ := range b.hashes {
|
||||
for i := range b.hashes {
|
||||
b.hashes[i] = rawdb.ReadCanonicalHash(pm.chainDb, uint64(rand.Int63n(randMax)))
|
||||
}
|
||||
return nil
|
||||
|
|
@ -117,9 +117,9 @@ func (b *benchmarkProofsOrCode) request(peer *peer, index int) error {
|
|||
key := make([]byte, 32)
|
||||
rand.Read(key)
|
||||
if b.code {
|
||||
return peer.RequestCode(0, 0, []CodeReq{CodeReq{BHash: b.headHash, AccKey: key}})
|
||||
return peer.RequestCode(0, 0, []CodeReq{{BHash: b.headHash, AccKey: key}})
|
||||
} else {
|
||||
return peer.RequestProofs(0, 0, []ProofReq{ProofReq{BHash: b.headHash, Key: key}})
|
||||
return peer.RequestProofs(0, 0, []ProofReq{{BHash: b.headHash, Key: key}})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,14 +149,14 @@ func (b *benchmarkHelperTrie) request(peer *peer, index int) error {
|
|||
|
||||
if b.bloom {
|
||||
bitIdx := uint16(rand.Intn(2048))
|
||||
for i, _ := range reqs {
|
||||
for i := range reqs {
|
||||
key := make([]byte, 10)
|
||||
binary.BigEndian.PutUint16(key[:2], bitIdx)
|
||||
binary.BigEndian.PutUint64(key[2:], uint64(rand.Int63n(int64(b.sectionCount))))
|
||||
reqs[i] = HelperTrieReq{Type: htBloomBits, TrieIdx: b.sectionCount - 1, Key: key}
|
||||
}
|
||||
} else {
|
||||
for i, _ := range reqs {
|
||||
for i := range reqs {
|
||||
key := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(key[:], uint64(rand.Int63n(int64(b.headNum))))
|
||||
reqs[i] = HelperTrieReq{Type: htCanonical, TrieIdx: b.sectionCount - 1, Key: key, AuxReq: auxHeader}
|
||||
|
|
@ -177,7 +177,7 @@ func (b *benchmarkTxSend) init(pm *ProtocolManager, count int) error {
|
|||
signer := types.NewEIP155Signer(big.NewInt(18))
|
||||
b.txs = make(types.Transactions, count)
|
||||
|
||||
for i, _ := range b.txs {
|
||||
for i := range b.txs {
|
||||
data := make([]byte, txSizeCostLimit)
|
||||
rand.Read(data)
|
||||
tx, err := types.SignTx(types.NewTransaction(0, addr, new(big.Int), 0, new(big.Int), data), signer, key)
|
||||
|
|
@ -288,7 +288,7 @@ func (pm *ProtocolManager) measure(setup *benchmarkSetup, count int) error {
|
|||
serverPeer.announceType = announceTypeNone
|
||||
serverPeer.fcCosts = make(requestCostTable)
|
||||
c := &requestCosts{}
|
||||
for code, _ := range requests {
|
||||
for code := range requests {
|
||||
serverPeer.fcCosts[code] = c
|
||||
}
|
||||
serverPeer.fcParams = flowcontrol.ServerParams{BufLimit: 1, MinRecharge: 1}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ const (
|
|||
)
|
||||
|
||||
// costTracker is responsible for calculating costs and cost estimates on the
|
||||
// server side. It continously updates the global cost factor which is defined
|
||||
// server side. It continuously updates the global cost factor which is defined
|
||||
// as the number of cost units per nanosecond of serving time in a single thread.
|
||||
// It is based on statistics collected during serving requests in high-load periods
|
||||
// and practically acts as a one-dimension request price scaling factor over the
|
||||
|
|
@ -127,7 +127,7 @@ func newCostTracker(db ethdb.Database, config *eth.Config) *costTracker {
|
|||
}
|
||||
if makeCostStats {
|
||||
ct.stats = make(map[uint64][]uint64)
|
||||
for code, _ := range reqAvgTimeCost {
|
||||
for code := range reqAvgTimeCost {
|
||||
ct.stats[code] = make([]uint64, 10)
|
||||
}
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ func (list RequestCostList) decode() requestCostTable {
|
|||
func testCostList() RequestCostList {
|
||||
cl := make(RequestCostList, len(reqAvgTimeCost))
|
||||
var max uint64
|
||||
for code, _ := range reqAvgTimeCost {
|
||||
for code := range reqAvgTimeCost {
|
||||
if code > max {
|
||||
max = code
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func (cm *ClientManager) SetRechargeCurve(curve PieceWiseLinear) {
|
|||
}
|
||||
|
||||
// connect should be called when a client is connected, before passing it to any
|
||||
// other ClientManager funtion
|
||||
// other ClientManager function
|
||||
func (cm *ClientManager) connect(node *ClientNode) {
|
||||
cm.lock.Lock()
|
||||
defer cm.lock.Unlock()
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func testConstantTotalCapacity(t *testing.T, nodeCount, maxCapacityNodes, random
|
|||
clock := &mclock.Simulated{}
|
||||
nodes := make([]*testNode, nodeCount)
|
||||
var totalCapacity uint64
|
||||
for i, _ := range nodes {
|
||||
for i := range nodes {
|
||||
nodes[i] = &testNode{capacity: uint64(50000 + rand.Intn(100000))}
|
||||
totalCapacity += nodes[i].capacity
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ func testConstantTotalCapacity(t *testing.T, nodeCount, maxCapacityNodes, random
|
|||
n.node = NewClientNode(m, ServerParams{BufLimit: n.bufLimit, MinRecharge: n.capacity})
|
||||
}
|
||||
maxNodes := make([]int, maxCapacityNodes)
|
||||
for i, _ := range maxNodes {
|
||||
for i := range maxNodes {
|
||||
// we don't care if some indexes are selected multiple times
|
||||
// in that case we have fewer max nodes
|
||||
maxNodes[i] = rand.Intn(nodeCount)
|
||||
|
|
|
|||
Loading…
Reference in a new issue