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"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/mclock"
|
"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
|
// requestDistributor implements a mechanism that distributes requests to
|
||||||
|
|
@ -195,7 +195,7 @@ func (d *requestDistributor) nextRequest() (distPeer, *distReq, time.Duration) {
|
||||||
elem := d.reqQueue.Front()
|
elem := d.reqQueue.Front()
|
||||||
var (
|
var (
|
||||||
bestWait time.Duration
|
bestWait time.Duration
|
||||||
sel *utilities.WeightedRandomSelect
|
sel *utils.WeightedRandomSelect
|
||||||
)
|
)
|
||||||
|
|
||||||
d.peerLock.RLock()
|
d.peerLock.RLock()
|
||||||
|
|
@ -220,7 +220,7 @@ func (d *requestDistributor) nextRequest() (distPeer, *distReq, time.Duration) {
|
||||||
wait, bufRemain := peer.waitBefore(cost)
|
wait, bufRemain := peer.waitBefore(cost)
|
||||||
if wait == 0 {
|
if wait == 0 {
|
||||||
if sel == nil {
|
if sel == nil {
|
||||||
sel = utilities.NewWeightedRandomSelect()
|
sel = utils.NewWeightedRandomSelect()
|
||||||
}
|
}
|
||||||
sel.Update(selectPeerItem{peer: peer, req: req, weight: int64(bufRemain*1000000) + 1})
|
sel.Update(selectPeerItem{peer: peer, req: req, weight: int64(bufRemain*1000000) + 1})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/les/flowcontrol"
|
"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/light"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
|
|
@ -136,7 +136,7 @@ type peerCommons struct {
|
||||||
headInfo blockInfo // Latest block information.
|
headInfo blockInfo // Latest block information.
|
||||||
|
|
||||||
// Background task queue for caching peer tasks and executing in order.
|
// Background task queue for caching peer tasks and executing in order.
|
||||||
sendQueue *utilities.ExecQueue
|
sendQueue *utils.ExecQueue
|
||||||
|
|
||||||
// Flow control agreement.
|
// Flow control agreement.
|
||||||
fcParams flowcontrol.ServerParams // The config for token bucket.
|
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()),
|
id: peerIdToString(p.ID()),
|
||||||
version: version,
|
version: version,
|
||||||
network: network,
|
network: network,
|
||||||
sendQueue: utilities.NewExecQueue(100),
|
sendQueue: utils.NewExecQueue(100),
|
||||||
closeCh: make(chan struct{}),
|
closeCh: make(chan struct{}),
|
||||||
},
|
},
|
||||||
trusted: trusted,
|
trusted: trusted,
|
||||||
|
|
@ -653,7 +653,7 @@ func newClientPeer(version int, network uint64, p *p2p.Peer, rw p2p.MsgReadWrite
|
||||||
id: peerIdToString(p.ID()),
|
id: peerIdToString(p.ID()),
|
||||||
version: version,
|
version: version,
|
||||||
network: network,
|
network: network,
|
||||||
sendQueue: utilities.NewExecQueue(100),
|
sendQueue: utils.NewExecQueue(100),
|
||||||
closeCh: make(chan struct{}),
|
closeCh: make(chan struct{}),
|
||||||
},
|
},
|
||||||
errCh: make(chan error, 1),
|
errCh: make(chan error, 1),
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common/mclock"
|
"github.com/ethereum/go-ethereum/common/mclock"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"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/log"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/p2p/discv5"
|
"github.com/ethereum/go-ethereum/p2p/discv5"
|
||||||
|
|
@ -130,7 +130,7 @@ type serverPool struct {
|
||||||
adjustStats chan poolStatAdjust
|
adjustStats chan poolStatAdjust
|
||||||
|
|
||||||
knownQueue, newQueue poolEntryQueue
|
knownQueue, newQueue poolEntryQueue
|
||||||
knownSelect, newSelect *utilities.WeightedRandomSelect
|
knownSelect, newSelect *utils.WeightedRandomSelect
|
||||||
knownSelected, newSelected int
|
knownSelected, newSelected int
|
||||||
fastDiscover bool
|
fastDiscover bool
|
||||||
connCh chan *connReq
|
connCh chan *connReq
|
||||||
|
|
@ -153,8 +153,8 @@ func newServerPool(db ethdb.Database, ulcServers []string) *serverPool {
|
||||||
disconnCh: make(chan *disconnReq),
|
disconnCh: make(chan *disconnReq),
|
||||||
registerCh: make(chan *registerReq),
|
registerCh: make(chan *registerReq),
|
||||||
closeCh: make(chan struct{}),
|
closeCh: make(chan struct{}),
|
||||||
knownSelect: utilities.NewWeightedRandomSelect(),
|
knownSelect: utils.NewWeightedRandomSelect(),
|
||||||
newSelect: utilities.NewWeightedRandomSelect(),
|
newSelect: utils.NewWeightedRandomSelect(),
|
||||||
fastDiscover: true,
|
fastDiscover: true,
|
||||||
trustedNodes: parseTrustedNodes(ulcServers),
|
trustedNodes: parseTrustedNodes(ulcServers),
|
||||||
}
|
}
|
||||||
|
|
@ -403,7 +403,7 @@ func (pool *serverPool) eventLoop() {
|
||||||
entry.lastConnected = addr
|
entry.lastConnected = addr
|
||||||
entry.addr = make(map[string]*poolEntryAddress)
|
entry.addr = make(map[string]*poolEntryAddress)
|
||||||
entry.addr[addr.strKey()] = addr
|
entry.addr[addr.strKey()] = addr
|
||||||
entry.addrSelect = *utilities.NewWeightedRandomSelect()
|
entry.addrSelect = *utils.NewWeightedRandomSelect()
|
||||||
entry.addrSelect.Update(addr)
|
entry.addrSelect.Update(addr)
|
||||||
req.result <- entry
|
req.result <- entry
|
||||||
}
|
}
|
||||||
|
|
@ -460,7 +460,7 @@ func (pool *serverPool) findOrNewNode(node *enode.Node) *poolEntry {
|
||||||
entry = &poolEntry{
|
entry = &poolEntry{
|
||||||
node: node,
|
node: node,
|
||||||
addr: make(map[string]*poolEntryAddress),
|
addr: make(map[string]*poolEntryAddress),
|
||||||
addrSelect: *utilities.NewWeightedRandomSelect(),
|
addrSelect: *utils.NewWeightedRandomSelect(),
|
||||||
shortRetry: shortRetryCnt,
|
shortRetry: shortRetryCnt,
|
||||||
}
|
}
|
||||||
pool.entries[node.ID()] = entry
|
pool.entries[node.ID()] = entry
|
||||||
|
|
@ -685,7 +685,7 @@ type poolEntry struct {
|
||||||
addr map[string]*poolEntryAddress
|
addr map[string]*poolEntryAddress
|
||||||
node *enode.Node
|
node *enode.Node
|
||||||
lastConnected, dialed *poolEntryAddress
|
lastConnected, dialed *poolEntryAddress
|
||||||
addrSelect utilities.WeightedRandomSelect
|
addrSelect utils.WeightedRandomSelect
|
||||||
|
|
||||||
lastDiscovered mclock.AbsTime
|
lastDiscovered mclock.AbsTime
|
||||||
known, knownSelected, trusted bool
|
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.node = enode.NewV4(pubkey, entry.IP, int(entry.Port), int(entry.Port))
|
||||||
e.addr = make(map[string]*poolEntryAddress)
|
e.addr = make(map[string]*poolEntryAddress)
|
||||||
e.addr[addr.strKey()] = addr
|
e.addr[addr.strKey()] = addr
|
||||||
e.addrSelect = *utilities.NewWeightedRandomSelect()
|
e.addrSelect = *utils.NewWeightedRandomSelect()
|
||||||
e.addrSelect.Update(addr)
|
e.addrSelect.Update(addr)
|
||||||
e.lastConnected = addr
|
e.lastConnected = addr
|
||||||
e.connectStats = entry.CStat
|
e.connectStats = entry.CStat
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// 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/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package utilities
|
package utils
|
||||||
|
|
||||||
import "sync"
|
import "sync"
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// 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/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package utilities
|
package utils
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// 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/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package utilities
|
package utils
|
||||||
|
|
||||||
import "math/rand"
|
import "math/rand"
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// 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/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package utilities
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
Loading…
Reference in a new issue