mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
les: fixed freeClientPool test
This commit is contained in:
parent
9a60499f9f
commit
1b1552b0ef
2 changed files with 5 additions and 6 deletions
|
|
@ -91,7 +91,9 @@ func (f *freeClientPool) stop() {
|
|||
// registerPeer implements clientPool
|
||||
func (f *freeClientPool) registerPeer(p *peer) {
|
||||
if addr, ok := p.RemoteAddr().(*net.TCPAddr); ok {
|
||||
f.connect(addr.IP.String(), p.id)
|
||||
if !f.connect(addr.IP.String(), p.id) {
|
||||
f.removePeer(p.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +109,6 @@ func (f *freeClientPool) connect(address, id string) bool {
|
|||
|
||||
if f.connectedLimit == 0 {
|
||||
log.Debug("Client rejected", "address", address)
|
||||
go f.removePeer(id)
|
||||
return false
|
||||
}
|
||||
e := f.addressMap[address]
|
||||
|
|
@ -119,7 +120,6 @@ func (f *freeClientPool) connect(address, id string) bool {
|
|||
} else {
|
||||
if e.connected {
|
||||
log.Debug("Client already connected", "address", address)
|
||||
go f.removePeer(id)
|
||||
return false
|
||||
}
|
||||
recentUsage = int64(math.Exp(float64(e.logUsage-f.logOffset(now)) / fixedPointMultiplier))
|
||||
|
|
@ -135,7 +135,6 @@ func (f *freeClientPool) connect(address, id string) bool {
|
|||
// keep the old client and reject the new one
|
||||
f.connPool.Push(i, i.linUsage)
|
||||
log.Debug("Client rejected", "address", address)
|
||||
go f.removePeer(id)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -206,7 +205,7 @@ func (f *freeClientPool) dropClient(i *freeClientPoolEntry, now mclock.AbsTime)
|
|||
i.connected = false
|
||||
f.disconnPool.Push(i, -i.logUsage)
|
||||
log.Debug("Client kicked out", "address", i.address)
|
||||
go f.removePeer(i.id)
|
||||
f.removePeer(i.id)
|
||||
}
|
||||
|
||||
// logOffset calculates the time-dependent offset for the logarithmic
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ func (s *LesServer) Start(srvr *p2p.Server) {
|
|||
log.Warn("Light peer count limited", "specified", s.maxPeers, "allowed", freePeers)
|
||||
}
|
||||
|
||||
s.freeClientPool = newFreeClientPool(s.chainDb, s.freeClientCap, 10000, mclock.System{}, s.protocolManager.removePeer)
|
||||
s.freeClientPool = newFreeClientPool(s.chainDb, s.freeClientCap, 10000, mclock.System{}, func(id string) { go s.protocolManager.removePeer(id) })
|
||||
s.priorityClientPool = newPriorityClientPool(s.freeClientCap, s.protocolManager.peers, s.freeClientPool)
|
||||
|
||||
s.protocolManager.peers.notify(s.priorityClientPool)
|
||||
|
|
|
|||
Loading…
Reference in a new issue