예제 #1
0
        private async Task StartLoop(CancellationToken token, Signaler tick)
        {
            try
            {
                int errors = 0;
                while (!token.IsCancellationRequested)
                {
                    errors = Math.Min(11, errors);
                    try
                    {
                        while (await StepAsync(token))
                        {
                        }
                        await tick.Wait(PollingInterval, token);

                        errors = 0;
                    }
                    catch (ConfigException) when(!token.IsCancellationRequested)
                    {
                        // Probably RPC errors, don't spam
                        await Wait(errors, tick, token);

                        errors++;
                    }
                    catch (Exception ex) when(!token.IsCancellationRequested)
                    {
                        Logs.Configuration.LogError(ex, $"{_Network.CryptoCode}: Unhandled in Waiter loop");
                        await Wait(errors, tick, token);

                        errors++;
                    }
                }
            }
            catch when(token.IsCancellationRequested)
            {
            }
            finally
            {
                EnsureNodeDisposed();
            }
        }
예제 #2
0
		private async Task Wait(int errors, Signaler tick, CancellationToken token)
		{
			var timeToWait = TimeSpan.FromSeconds(5.0) * (errors + 1);
			Logs.Configuration.LogInformation($"{_Network.CryptoCode}: Testing again in {(int)timeToWait.TotalSeconds} seconds");
			await tick.Wait(timeToWait, token);
		}