diff --git a/les/distributor.go b/les/distributor.go
index fab1d3f1b8..97d2ccdfea 100644
--- a/les/distributor.go
+++ b/les/distributor.go
@@ -22,7 +22,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/common/mclock"
- "github.com/ethereum/go-ethereum/les/utilities"
+ "github.com/ethereum/go-ethereum/les/utils"
)
// requestDistributor implements a mechanism that distributes requests to
@@ -195,7 +195,7 @@ func (d *requestDistributor) nextRequest() (distPeer, *distReq, time.Duration) {
elem := d.reqQueue.Front()
var (
bestWait time.Duration
- sel *utilities.WeightedRandomSelect
+ sel *utils.WeightedRandomSelect
)
d.peerLock.RLock()
@@ -220,7 +220,7 @@ func (d *requestDistributor) nextRequest() (distPeer, *distReq, time.Duration) {
wait, bufRemain := peer.waitBefore(cost)
if wait == 0 {
if sel == nil {
- sel = utilities.NewWeightedRandomSelect()
+ sel = utils.NewWeightedRandomSelect()
}
sel.Update(selectPeerItem{peer: peer, req: req, weight: int64(bufRemain*1000000) + 1})
} else {
diff --git a/les/peer.go b/les/peer.go
index 579787313c..c2f4235eb4 100644
--- a/les/peer.go
+++ b/les/peer.go
@@ -32,7 +32,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/les/flowcontrol"
- "github.com/ethereum/go-ethereum/les/utilities"
+ "github.com/ethereum/go-ethereum/les/utils"
"github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode"
@@ -136,7 +136,7 @@ type peerCommons struct {
headInfo blockInfo // Latest block information.
// Background task queue for caching peer tasks and executing in order.
- sendQueue *utilities.ExecQueue
+ sendQueue *utils.ExecQueue
// Flow control agreement.
fcParams flowcontrol.ServerParams // The config for token bucket.
@@ -376,7 +376,7 @@ func newServerPeer(version int, network uint64, trusted bool, p *p2p.Peer, rw p2
id: peerIdToString(p.ID()),
version: version,
network: network,
- sendQueue: utilities.NewExecQueue(100),
+ sendQueue: utils.NewExecQueue(100),
closeCh: make(chan struct{}),
},
trusted: trusted,
@@ -653,7 +653,7 @@ func newClientPeer(version int, network uint64, p *p2p.Peer, rw p2p.MsgReadWrite
id: peerIdToString(p.ID()),
version: version,
network: network,
- sendQueue: utilities.NewExecQueue(100),
+ sendQueue: utils.NewExecQueue(100),
closeCh: make(chan struct{}),
},
errCh: make(chan error, 1),
diff --git a/les/serverpool.go b/les/serverpool.go
index c72353825d..d1c53295a7 100644
--- a/les/serverpool.go
+++ b/les/serverpool.go
@@ -30,7 +30,7 @@ import (
"github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/les/utilities"
+ "github.com/ethereum/go-ethereum/les/utils"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discv5"
@@ -130,7 +130,7 @@ type serverPool struct {
adjustStats chan poolStatAdjust
knownQueue, newQueue poolEntryQueue
- knownSelect, newSelect *utilities.WeightedRandomSelect
+ knownSelect, newSelect *utils.WeightedRandomSelect
knownSelected, newSelected int
fastDiscover bool
connCh chan *connReq
@@ -153,8 +153,8 @@ func newServerPool(db ethdb.Database, ulcServers []string) *serverPool {
disconnCh: make(chan *disconnReq),
registerCh: make(chan *registerReq),
closeCh: make(chan struct{}),
- knownSelect: utilities.NewWeightedRandomSelect(),
- newSelect: utilities.NewWeightedRandomSelect(),
+ knownSelect: utils.NewWeightedRandomSelect(),
+ newSelect: utils.NewWeightedRandomSelect(),
fastDiscover: true,
trustedNodes: parseTrustedNodes(ulcServers),
}
@@ -403,7 +403,7 @@ func (pool *serverPool) eventLoop() {
entry.lastConnected = addr
entry.addr = make(map[string]*poolEntryAddress)
entry.addr[addr.strKey()] = addr
- entry.addrSelect = *utilities.NewWeightedRandomSelect()
+ entry.addrSelect = *utils.NewWeightedRandomSelect()
entry.addrSelect.Update(addr)
req.result <- entry
}
@@ -460,7 +460,7 @@ func (pool *serverPool) findOrNewNode(node *enode.Node) *poolEntry {
entry = &poolEntry{
node: node,
addr: make(map[string]*poolEntryAddress),
- addrSelect: *utilities.NewWeightedRandomSelect(),
+ addrSelect: *utils.NewWeightedRandomSelect(),
shortRetry: shortRetryCnt,
}
pool.entries[node.ID()] = entry
@@ -685,7 +685,7 @@ type poolEntry struct {
addr map[string]*poolEntryAddress
node *enode.Node
lastConnected, dialed *poolEntryAddress
- addrSelect utilities.WeightedRandomSelect
+ addrSelect utils.WeightedRandomSelect
lastDiscovered mclock.AbsTime
known, knownSelected, trusted bool
@@ -735,7 +735,7 @@ func (e *poolEntry) DecodeRLP(s *rlp.Stream) error {
e.node = enode.NewV4(pubkey, entry.IP, int(entry.Port), int(entry.Port))
e.addr = make(map[string]*poolEntryAddress)
e.addr[addr.strKey()] = addr
- e.addrSelect = *utilities.NewWeightedRandomSelect()
+ e.addrSelect = *utils.NewWeightedRandomSelect()
e.addrSelect.Update(addr)
e.lastConnected = addr
e.connectStats = entry.CStat
diff --git a/les/utilities/exec_queue.go b/les/utils/exec_queue.go
similarity index 99%
rename from les/utilities/exec_queue.go
rename to les/utils/exec_queue.go
index 8a77178051..a8f9b84acb 100644
--- a/les/utilities/exec_queue.go
+++ b/les/utils/exec_queue.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package utilities
+package utils
import "sync"
diff --git a/les/utilities/exec_queue_test.go b/les/utils/exec_queue_test.go
similarity index 98%
rename from les/utilities/exec_queue_test.go
rename to les/utils/exec_queue_test.go
index 81a04c381d..98601c4486 100644
--- a/les/utilities/exec_queue_test.go
+++ b/les/utils/exec_queue_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package utilities
+package utils
import "testing"
diff --git a/les/utilities/weighted_select.go b/les/utils/weighted_select.go
similarity index 99%
rename from les/utilities/weighted_select.go
rename to les/utils/weighted_select.go
index 85dd13cb5e..fbf1f37d62 100644
--- a/les/utilities/weighted_select.go
+++ b/les/utils/weighted_select.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package utilities
+package utils
import "math/rand"
diff --git a/les/utilities/weighted_select_test.go b/les/utils/weighted_select_test.go
similarity index 98%
rename from les/utilities/weighted_select_test.go
rename to les/utils/weighted_select_test.go
index 4e81c0c086..e1969e1a61 100644
--- a/les/utilities/weighted_select_test.go
+++ b/les/utils/weighted_select_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-package utilities
+package utils
import (
"math/rand"