Exemplo n.º 1
0
        /// <inheritdoc />
        public async Task <PinResult> PinAsync(Context context, ContentHash contentHash)
        {
            StructResult <int> sessionResult = await _sessionState.GetIdAsync();

            if (!sessionResult.Succeeded)
            {
                return(new PinResult(sessionResult));
            }

            int sessionId = sessionResult.Data;

            DateTime    startTime = DateTime.UtcNow;
            PinResponse response  = await RunClientActionAndThrowIfFailedAsync(
                context,
                async() => await _client.PinAsync(
                    new PinRequest
            {
                HashType    = (int)contentHash.HashType,
                ContentHash = contentHash.ToByteString(),
                Header      = new RequestHeader(context.Id, sessionId)
            }));

            long ticksWaited = response.Header.ServerReceiptTimeUtcTicks - startTime.Ticks;

            _tracer.TrackClientWaitForServerTicks(ticksWaited);

            await ResetOnUnknownSessionAsync(context, response.Header, sessionId);

            return(UnpackPinResult(response.Header));
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 public Task <PinResult> PinAsync(Context context, ContentHash contentHash)
 {
     return(PerformOperationAsync(
                new OperationContext(context),
                sessionContext => _client.PinAsync(
                    new PinRequest
     {
         HashType = (int)contentHash.HashType,
         ContentHash = contentHash.ToByteString(),
         Header = sessionContext.CreateHeader(),
     }),
                response => UnpackPinResult(response.Header)
                ));
 }