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 peerProtocolLimit = limiter.getProtocolPeerLimits(this.protocol, peerId);
    final scopeName = 'protocol:${protocol.toString()}-peer:${peerId.toString()}';

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