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 // ServerInfo returns global server parameters
func (api *PrivateLightServerAPI) ServerInfo() map[string]interface{} { func (api *PrivateLightServerAPI) ServerInfo() map[string]interface{} {
res := make(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["freeClientCapacity"] = api.server.freeClientCap
res["totalCapacity"], res["totalConnectedCapacity"], res["priorityConnectedCapacity"], res["totalPriorityCapacity"] = api.server.priorityClientPool.capacityInfo() res["totalCapacity"], res["totalConnectedCapacity"], res["priorityConnectedCapacity"], res["totalPriorityCapacity"] = api.server.priorityClientPool.capacityInfo()
return res return res

View file

@ -66,7 +66,7 @@ type LesServer struct {
thcNormal, thcBlockProcessing int // serving thread count for normal operation and block processing mode thcNormal, thcBlockProcessing int // serving thread count for normal operation and block processing mode
maxPeers int maxPeers int
minCapacity, freeClientCap uint64 minCapacity, maxCapacity, freeClientCap uint64
freeClientPool *freeClientPool freeClientPool *freeClientPool
priorityClientPool *priorityClientPool priorityClientPool *priorityClientPool
} }
@ -236,11 +236,11 @@ func (s *LesServer) Start(srvr *p2p.Server) {
} }
} }
maxCapacity := s.freeClientCap * uint64(s.maxPeers) s.maxCapacity = s.freeClientCap * uint64(s.maxPeers)
if totalRecharge > maxCapacity { if totalRecharge > s.maxCapacity {
maxCapacity = totalRecharge 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 poolMetricsLogger := s.csvLogger
if !logClientPoolMetrics { if !logClientPoolMetrics {
poolMetricsLogger = nil poolMetricsLogger = nil