Esempio n. 1
0
        public async Task <IActionResult> Broadcast([Required, FromBody] BroadcastTransactionRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.ToErrorResponse()));
            }

            var transaction = _dynamicService.GetTransaction(request.SignedTransaction);

            if (transaction == null)
            {
                return(BadRequest(ErrorResponse.Create($"{nameof(request.SignedTransaction)} is not a valid")));
            }

            var broadcast = await _dynamicService.GetBroadcastAsync(request.OperationId);

            if (broadcast != null)
            {
                return(new StatusCodeResult(StatusCodes.Status409Conflict));
            }

            await _log.WriteInfoAsync(nameof(TransactionsController), nameof(Broadcast),
                                      request.ToJson(), "Broadcast transaction");

            await _dynamicService.BroadcastAsync(transaction, request.OperationId);

            return(Ok());
        }