code: func (v *priorityClientPool) setClientCapacity(id enode.ID, cap uint64) error {
  	v.lock.Lock()
  	defer v.lock.Unlock()
  
  	c := v.clients[id]
  	if c.cap == cap {
  		return nil
  	}
  	if c.connected {
  		if v.totalConnectedCap+cap > v.totalCap+c.cap {
  			return ErrTotalCap
  		}
  		if c.cap == 0 {
  			if v.child != nil {
  				v.child.unregisterPeer(c.peer)
  			}
  			v.priorityCount++
  		}
  		if cap == 0 {
  			v.priorityCount--
  		}
  		v.totalConnectedCap += cap - c.cap
  		if v.child != nil {
  			v.child.setLimits(v.maxPeers-v.priorityCount, v.totalCap-v.totalConnectedCap)
  		}
  		if cap == 0 {
  			if v.child != nil {
  				v.child.registerPeer(c.peer)
  			}
  			c.peer.updateCapacity(v.freeClientCap)
  		} else {
  			c.peer.updateCapacity(cap)
  		}
  	}
  	if cap != 0 || c.connected {
  		c.cap = cap
  		v.clients[id] = c
  	} else {
  		delete(v.clients, id)
  	}
  	return nil
  }
docs: // setClientCapacity sets the priority capacity assigned to a given client