49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Security.Cryptography;
|
|
using System.Threading;
|
|
|
|
using FrostFS.SDK.Cryptography;
|
|
|
|
using Google.Protobuf;
|
|
|
|
using Grpc.Core.Interceptors;
|
|
|
|
namespace FrostFS.SDK.ClientV2;
|
|
|
|
public class Context()
|
|
{
|
|
private List<Interceptor>? interceptors;
|
|
|
|
private ByteString? publicKeyCache;
|
|
|
|
public ECDsa Key { get; set; }
|
|
|
|
public FrostFsOwner OwnerId { get; set; }
|
|
|
|
public FrostFsVersion Version { get; set; }
|
|
|
|
public CancellationToken CancellationToken { get; set; } = default;
|
|
|
|
public TimeSpan Timeout { get; set; } = default;
|
|
|
|
public DateTime? Deadline => Timeout.Ticks > 0 ? DateTime.UtcNow.Add(Timeout) : null;
|
|
|
|
public Action<CallStatistics>? Callback { get; set; }
|
|
|
|
public List<Interceptor> Interceptors
|
|
{
|
|
get { return this.interceptors ??= []; }
|
|
set { this.interceptors = value; }
|
|
}
|
|
|
|
public ByteString? GetPublicKeyCache()
|
|
{
|
|
if (publicKeyCache == null && Key != null)
|
|
{
|
|
publicKeyCache = ByteString.CopyFrom(Key.PublicKey());
|
|
}
|
|
|
|
return publicKeyCache;
|
|
}
|
|
}
|