les: expose maximumCapacity

This commit is contained in:
Zsolt Felfoldi 2019-06-07 16:24:18 +02:00
parent 9404302778
commit b10612d685
2 changed files with 10 additions and 9 deletions

View file

@ -59,7 +59,8 @@ func NewPrivateLightServerAPI(server *LesServer) *PrivateLightServerAPI {
// ServerInfo returns global server parameters
func (api *PrivateLightServerAPI) ServerInfo() map[string]interface{} {
res := make(map[string]interface{})
res["minimumCapacity"] = uint64(api.server.minCapacity)
res["minimumCapacity"] = api.server.minCapacity
res["maximumCapacity"] = api.server.maxCapacity
res["freeClientCapacity"] = api.server.freeClientCap
res["totalCapacity"], res["totalConnectedCapacity"], res["priorityConnectedCapacity"], res["totalPriorityCapacity"] = api.server.priorityClientPool.capacityInfo()
return res

View file

@ -65,10 +65,10 @@ type LesServer struct {
thcNormal, thcBlockProcessing int // serving thread count for normal operation and block processing mode
maxPeers int
minCapacity, freeClientCap uint64
freeClientPool *freeClientPool
priorityClientPool *priorityClientPool
maxPeers int
minCapacity, maxCapacity, freeClientCap uint64
freeClientPool *freeClientPool
priorityClientPool *priorityClientPool
}
func NewLesServer(e *eth.Ethereum, config *eth.Config) (*LesServer, error) {
@ -236,11 +236,11 @@ func (s *LesServer) Start(srvr *p2p.Server) {
}
}
maxCapacity := s.freeClientCap * uint64(s.maxPeers)
if totalRecharge > maxCapacity {
maxCapacity = totalRecharge
s.maxCapacity = s.freeClientCap * uint64(s.maxPeers)
if totalRecharge > s.maxCapacity {
s.maxCapacity = totalRecharge
}
s.fcManager.SetCapacityLimits(s.freeClientCap, maxCapacity, s.freeClientCap*2)
s.fcManager.SetCapacityLimits(s.freeClientCap, s.maxCapacity, s.freeClientCap*2)
poolMetricsLogger := s.csvLogger
if !logClientPoolMetrics {
poolMetricsLogger = nil