Пример #1
0
        private async Task <GetLogsResponse?> GetLogsAsync(OrchestrationProgress progress, BigInteger fromBlock, BigInteger toBlock, int retryRequestNumber = 0)
        {
            try
            {
                var adjustedToBlock =
                    _blockRangeRequestStrategy.GeBlockNumberToRequestTo(fromBlock, toBlock,
                                                                        retryRequestNumber);

                _filterInput.SetBlockRange(fromBlock, adjustedToBlock);

                var logs = await EthApi.Filters.GetLogs.SendRequestAsync(_filterInput).ConfigureAwait(false);

                return(new GetLogsResponse(fromBlock, adjustedToBlock, logs));
            }
            catch (Exception ex)
            {
                if (retryRequestNumber >= MaxGetLogsRetries)
                {
                    progress.Exception = ex;
                    return(null);
                }
                else
                {
                    return(await GetLogsAsync(progress, fromBlock, toBlock, retryRequestNumber + 1).ConfigureAwait(false));
                }
            }
        }
Пример #2
0
        private async Task <GetLogsResponse?> GetLogsAsync(OrchestrationProgress progress, BigInteger fromBlock, BigInteger toBlock, int retryRequestNumber = 0, int retryNullLogsRequestNumber = 0)
        {
            try
            {
                var adjustedToBlock =
                    _blockRangeRequestStrategy.GeBlockNumberToRequestTo(fromBlock, toBlock,
                                                                        retryRequestNumber);

                _filterInput.SetBlockRange(fromBlock, adjustedToBlock);

                var logs = await EthApi.Filters.GetLogs.SendRequestAsync(_filterInput).ConfigureAwait(false);

                //If we don't get any, lets retry in case there is an issue with the node.
                if (logs == null && retryNullLogsRequestNumber < MaxGetLogsNullRetries)
                {
                    return(await GetLogsAsync(progress, fromBlock, toBlock, 0, retryNullLogsRequestNumber + 1).ConfigureAwait(false));
                }
                retryRequestNumber         = 0;
                retryNullLogsRequestNumber = 0;
                return(new GetLogsResponse(fromBlock, adjustedToBlock, logs));
            }
            catch (Exception ex)
            {
                if (retryRequestNumber >= MaxGetLogsRetries)
                {
                    progress.Exception = ex;
                    return(null);
                }
                else
                {
                    return(await GetLogsAsync(progress, fromBlock, toBlock, retryRequestNumber + 1).ConfigureAwait(false));
                }
            }
        }