Exemplo n.º 1
0
        public async Task <string> GetContractRaw()
        {
            Action throwAction = () =>
            {
                _slackNotifier.ErrorAsync("Chronobank integration! User contract pool is empty!");
                throw new BackendException("User contract pool is empty!", ErrorCode.ContractPoolEmpty);
            };
            var message = await _queue.GetRawMessageAsync();

            if (message == null)
            {
                throwAction();
            }

            await _queue.FinishRawMessageAsync(message);

            var contract = message.AsString;

            if (string.IsNullOrWhiteSpace(contract))
            {
                throwAction();
            }

            return(contract);
        }
 public Task CompleteAsync(
     T task)
 {
     return(_queue.FinishRawMessageAsync(new CloudQueueMessage
                                         (
                                             messageId: task.MessageId,
                                             popReceipt: task.PopReceipt
                                         )));
 }
Exemplo n.º 3
0
        public Task FinishMessageAsync(IQueueMessage msg)
        {
            var internalMsg = (msg as AzureMessage)?.Msg;

            if (internalMsg != null)
            {
                return(_queue.FinishRawMessageAsync(internalMsg));
            }
            return(Task.CompletedTask);
        }
Exemplo n.º 4
0
        public async Task <Coin> DequeueCoin()
        {
            var msg = await _queue.GetRawMessageAsync();

            if (msg == null)
            {
                throw new BackendException($"Pregenerated pool '{_queueName}' is empty!", ErrorCode.PregeneratedPoolIsEmpty);
            }

            await _queue.FinishRawMessageAsync(msg);

            return(msg.AsString.DeserializeJson <SerializableCoin>().ToCoin());
        }
Exemplo n.º 5
0
        public async Task Start()
        {
            int?cnt = 0;
            int i   = 0;

            while ((cnt = await _fromQueue.Count()) > 0)
            {
                var msg = await _fromQueue.GetRawMessageAsync();

                await _toQueue.PutRawMessageAsync(msg.AsString);

                await _fromQueue.FinishRawMessageAsync(msg);

                Console.WriteLine($"Processed {++i} from {cnt}");
            }
        }
Exemplo n.º 6
0
        public async Task <string> GetContractAddress()
        {
            var message = await _queue.GetRawMessageAsync();

            if (message != null)
            {
                await _queue.FinishRawMessageAsync(message);

                return(message.AsString);
            }
            else
            {
                await _slackNotifier.ErrorAsync("Ethereum Core Service! Erc20 deposit contract pool is empty!");

                throw new ClientSideException(ExceptionType.ContractPoolEmpty, "Erc20 deposit contract pool is empty!");
            }
        }
        public async Task RemoveFromPendingOperationQueue(string opId)
        {
            var count = await _queue.Count();

            for (int i = 0; i < count; i++)
            {
                var message = await _queue.GetRawMessageAsync();

                OperationHashMatchMessage newMessage = JsonConvert.DeserializeObject <OperationHashMatchMessage>(message.AsString);

                await _queue.FinishRawMessageAsync(message);

                if (newMessage.OperationId?.ToLower() != opId?.ToLower())
                {
                    await _queue.PutRawMessageAsync(message.AsString);
                }
            }
        }
        public async Task <string> GetContractRaw()
        {
            //TODO: think about locking code below
            var message = await _queue.GetRawMessageAsync();

            if (message == null)
            {
                NotifyAboutError();
            }

            await _queue.FinishRawMessageAsync(message);

            var contract = message.AsString;

            if (string.IsNullOrWhiteSpace(contract))
            {
                NotifyAboutError();
            }

            return(contract);
        }
Exemplo n.º 9
0
        private async Task FinishMessage()
        {
            var msg = await _incomeQueue.GetRawMessageAsync();

            await _incomeQueue.FinishRawMessageAsync(msg);
        }
Exemplo n.º 10
0
 public Task FinishRawMessageAsync(CloudQueueMessage msg)
 => WrapAsync(() => _impl.FinishRawMessageAsync(msg), Name);