using FrostFS.SDK.ModelsV2; using Google.Protobuf; using Grpc.Net.Client; using System; using System.Security.Cryptography; using FrostFS.SDK.Cryptography; using System.Buffers; namespace FrostFS.SDK.ClientV2; public class ClientEnvironment(Client client, ECDsa key, OwnerId owner, GrpcChannel channel, ModelsV2.Version version) : IDisposable { private ArrayPool _arrayPool; internal OwnerId Owner { get; } = owner; internal GrpcChannel Channel { get; private set; } = channel; internal ModelsV2.Version Version { get; } = version; internal NetworkSettings? NetworkSettings { get; set; } internal Client Client { get; } = client; internal ClientKey Key { get; } = new ClientKey(key); /// /// Custom pool is used for predefined sizes of buffers like grpc chunk /// internal ArrayPool GetArrayPool(int size) { _arrayPool ??= ArrayPool.Create(size, 256); return _arrayPool; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { Channel.Dispose(); } } }