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
|
// send sends a changed total capacity event to the subscribers
|
||||||
func (s tcSubs) send(tc uint64, underrun bool) {
|
func (s tcSubs) send(tc uint64, underrun bool) {
|
||||||
for sub, _ := range s {
|
for sub := range s {
|
||||||
select {
|
select {
|
||||||
case <-sub.rpcSub.Err():
|
case <-sub.rpcSub.Err():
|
||||||
delete(s, sub)
|
delete(s, sub)
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ func testCapacityAPI(t *testing.T, clientCount int) {
|
||||||
|
|
||||||
processedSince := func(start []uint64) []uint64 {
|
processedSince := func(start []uint64) []uint64 {
|
||||||
res := make([]uint64, len(reqCount))
|
res := make([]uint64, len(reqCount))
|
||||||
for i, _ := range reqCount {
|
for i := range reqCount {
|
||||||
res[i] = atomic.LoadUint64(&reqCount[i])
|
res[i] = atomic.LoadUint64(&reqCount[i])
|
||||||
if start != nil {
|
if start != nil {
|
||||||
res[i] -= start[i]
|
res[i] -= start[i]
|
||||||
|
|
@ -197,7 +197,7 @@ func testCapacityAPI(t *testing.T, clientCount int) {
|
||||||
setCapacity(ctx, t, serverRpcClient, clients[freeIdx].ID(), freeCap)
|
setCapacity(ctx, t, serverRpcClient, clients[freeIdx].ID(), freeCap)
|
||||||
freeIdx = rand.Intn(len(clients))
|
freeIdx = rand.Intn(len(clients))
|
||||||
var sum float64
|
var sum float64
|
||||||
for i, _ := range clients {
|
for i := range clients {
|
||||||
if i == freeIdx {
|
if i == freeIdx {
|
||||||
weights[i] = 0
|
weights[i] = 0
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -220,14 +220,14 @@ func testCapacityAPI(t *testing.T, clientCount int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
weights[freeIdx] = float64(freeCap)
|
weights[freeIdx] = float64(freeCap)
|
||||||
for i, _ := range clients {
|
for i := range clients {
|
||||||
weights[i] /= float64(testCap)
|
weights[i] /= float64(testCap)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(flowcontrol.DecParamDelay)
|
time.Sleep(flowcontrol.DecParamDelay)
|
||||||
fmt.Println("Starting measurement")
|
fmt.Println("Starting measurement")
|
||||||
fmt.Printf("Relative weights:")
|
fmt.Printf("Relative weights:")
|
||||||
for i, _ := range clients {
|
for i := range clients {
|
||||||
fmt.Printf(" %f", weights[i])
|
fmt.Printf(" %f", weights[i])
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
@ -459,7 +459,7 @@ func testSim(t *testing.T, serverCount, clientCount int, serverDir, clientDir []
|
||||||
servers := make([]*simulations.Node, serverCount)
|
servers := make([]*simulations.Node, serverCount)
|
||||||
clients := make([]*simulations.Node, clientCount)
|
clients := make([]*simulations.Node, clientCount)
|
||||||
|
|
||||||
for i, _ := range clients {
|
for i := range clients {
|
||||||
clientconf := adapters.RandomNodeConfig()
|
clientconf := adapters.RandomNodeConfig()
|
||||||
clientconf.Services = []string{"lesclient"}
|
clientconf.Services = []string{"lesclient"}
|
||||||
if len(clientDir) == clientCount {
|
if len(clientDir) == clientCount {
|
||||||
|
|
@ -472,7 +472,7 @@ func testSim(t *testing.T, serverCount, clientCount int, serverDir, clientDir []
|
||||||
clients[i] = client
|
clients[i] = client
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, _ := range servers {
|
for i := range servers {
|
||||||
serverconf := adapters.RandomNodeConfig()
|
serverconf := adapters.RandomNodeConfig()
|
||||||
serverconf.Services = []string{"lesserver"}
|
serverconf.Services = []string{"lesserver"}
|
||||||
if len(serverDir) == serverCount {
|
if len(serverDir) == serverCount {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func (b *benchmarkBlockHeaders) init(pm *ProtocolManager, count int) error {
|
||||||
}
|
}
|
||||||
if b.byHash {
|
if b.byHash {
|
||||||
b.hashes = make([]common.Hash, count)
|
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)))
|
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 {
|
func (b *benchmarkBodiesOrReceipts) init(pm *ProtocolManager, count int) error {
|
||||||
randMax := pm.blockchain.CurrentHeader().Number.Int64() + 1
|
randMax := pm.blockchain.CurrentHeader().Number.Int64() + 1
|
||||||
b.hashes = make([]common.Hash, count)
|
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)))
|
b.hashes[i] = rawdb.ReadCanonicalHash(pm.chainDb, uint64(rand.Int63n(randMax)))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -117,9 +117,9 @@ func (b *benchmarkProofsOrCode) request(peer *peer, index int) error {
|
||||||
key := make([]byte, 32)
|
key := make([]byte, 32)
|
||||||
rand.Read(key)
|
rand.Read(key)
|
||||||
if b.code {
|
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 {
|
} 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 {
|
if b.bloom {
|
||||||
bitIdx := uint16(rand.Intn(2048))
|
bitIdx := uint16(rand.Intn(2048))
|
||||||
for i, _ := range reqs {
|
for i := range reqs {
|
||||||
key := make([]byte, 10)
|
key := make([]byte, 10)
|
||||||
binary.BigEndian.PutUint16(key[:2], bitIdx)
|
binary.BigEndian.PutUint16(key[:2], bitIdx)
|
||||||
binary.BigEndian.PutUint64(key[2:], uint64(rand.Int63n(int64(b.sectionCount))))
|
binary.BigEndian.PutUint64(key[2:], uint64(rand.Int63n(int64(b.sectionCount))))
|
||||||
reqs[i] = HelperTrieReq{Type: htBloomBits, TrieIdx: b.sectionCount - 1, Key: key}
|
reqs[i] = HelperTrieReq{Type: htBloomBits, TrieIdx: b.sectionCount - 1, Key: key}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i, _ := range reqs {
|
for i := range reqs {
|
||||||
key := make([]byte, 8)
|
key := make([]byte, 8)
|
||||||
binary.BigEndian.PutUint64(key[:], uint64(rand.Int63n(int64(b.headNum))))
|
binary.BigEndian.PutUint64(key[:], uint64(rand.Int63n(int64(b.headNum))))
|
||||||
reqs[i] = HelperTrieReq{Type: htCanonical, TrieIdx: b.sectionCount - 1, Key: key, AuxReq: auxHeader}
|
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))
|
signer := types.NewEIP155Signer(big.NewInt(18))
|
||||||
b.txs = make(types.Transactions, count)
|
b.txs = make(types.Transactions, count)
|
||||||
|
|
||||||
for i, _ := range b.txs {
|
for i := range b.txs {
|
||||||
data := make([]byte, txSizeCostLimit)
|
data := make([]byte, txSizeCostLimit)
|
||||||
rand.Read(data)
|
rand.Read(data)
|
||||||
tx, err := types.SignTx(types.NewTransaction(0, addr, new(big.Int), 0, new(big.Int), data), signer, key)
|
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.announceType = announceTypeNone
|
||||||
serverPeer.fcCosts = make(requestCostTable)
|
serverPeer.fcCosts = make(requestCostTable)
|
||||||
c := &requestCosts{}
|
c := &requestCosts{}
|
||||||
for code, _ := range requests {
|
for code := range requests {
|
||||||
serverPeer.fcCosts[code] = c
|
serverPeer.fcCosts[code] = c
|
||||||
}
|
}
|
||||||
serverPeer.fcParams = flowcontrol.ServerParams{BufLimit: 1, MinRecharge: 1}
|
serverPeer.fcParams = flowcontrol.ServerParams{BufLimit: 1, MinRecharge: 1}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// costTracker is responsible for calculating costs and cost estimates on the
|
// 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.
|
// 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
|
// 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
|
// 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 {
|
if makeCostStats {
|
||||||
ct.stats = make(map[uint64][]uint64)
|
ct.stats = make(map[uint64][]uint64)
|
||||||
for code, _ := range reqAvgTimeCost {
|
for code := range reqAvgTimeCost {
|
||||||
ct.stats[code] = make([]uint64, 10)
|
ct.stats[code] = make([]uint64, 10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,7 +370,7 @@ func (list RequestCostList) decode() requestCostTable {
|
||||||
func testCostList() RequestCostList {
|
func testCostList() RequestCostList {
|
||||||
cl := make(RequestCostList, len(reqAvgTimeCost))
|
cl := make(RequestCostList, len(reqAvgTimeCost))
|
||||||
var max uint64
|
var max uint64
|
||||||
for code, _ := range reqAvgTimeCost {
|
for code := range reqAvgTimeCost {
|
||||||
if code > max {
|
if code > max {
|
||||||
max = code
|
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
|
// 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) {
|
func (cm *ClientManager) connect(node *ClientNode) {
|
||||||
cm.lock.Lock()
|
cm.lock.Lock()
|
||||||
defer cm.lock.Unlock()
|
defer cm.lock.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ func testConstantTotalCapacity(t *testing.T, nodeCount, maxCapacityNodes, random
|
||||||
clock := &mclock.Simulated{}
|
clock := &mclock.Simulated{}
|
||||||
nodes := make([]*testNode, nodeCount)
|
nodes := make([]*testNode, nodeCount)
|
||||||
var totalCapacity uint64
|
var totalCapacity uint64
|
||||||
for i, _ := range nodes {
|
for i := range nodes {
|
||||||
nodes[i] = &testNode{capacity: uint64(50000 + rand.Intn(100000))}
|
nodes[i] = &testNode{capacity: uint64(50000 + rand.Intn(100000))}
|
||||||
totalCapacity += nodes[i].capacity
|
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})
|
n.node = NewClientNode(m, ServerParams{BufLimit: n.bufLimit, MinRecharge: n.capacity})
|
||||||
}
|
}
|
||||||
maxNodes := make([]int, maxCapacityNodes)
|
maxNodes := make([]int, maxCapacityNodes)
|
||||||
for i, _ := range maxNodes {
|
for i := range maxNodes {
|
||||||
// we don't care if some indexes are selected multiple times
|
// we don't care if some indexes are selected multiple times
|
||||||
// in that case we have fewer max nodes
|
// in that case we have fewer max nodes
|
||||||
maxNodes[i] = rand.Intn(nodeCount)
|
maxNodes[i] = rand.Intn(nodeCount)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue