mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
les: rename to utils
This commit is contained in:
parent
2111120551
commit
6b7a2569f0
7 changed files with 19 additions and 19 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package utilities
|
||||
package utils
|
||||
|
||||
import "sync"
|
||||
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package utilities
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package utilities
|
||||
package utils
|
||||
|
||||
import "math/rand"
|
||||
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package utilities
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
Loading…
Reference in a new issue