getPeerSubScope method

ResourceScopeImpl getPeerSubScope(
  1. PeerId peerId,
  2. Limiter limiter,
  3. ResourceScopeImpl systemScope
)

Implementation

ResourceScopeImpl getPeerSubScope(PeerId peerId, Limiter limiter, ResourceScopeImpl systemScope) {
  return _peerSubScopes.putIfAbsent(peerId, () {
    final peerServiceLimit = limiter.getServicePeerLimits(this.name, peerId);
    final scopeName = 'service:${this.name}-peer:${peerId.toString()}';

    final newPeerSubScope = ResourceScopeImpl(
      peerServiceLimit,
      scopeName,
      edges: [this, systemScope], // Parent is this service scope and system scope
    );
    newPeerSubScope.incRef(); // This sub-scope is now in use
    return newPeerSubScope;
  });
}