Skip to content

Commit

Permalink
Build WasabiSyncer
Browse files Browse the repository at this point in the history
  • Loading branch information
nopara73 committed Dec 19, 2018
1 parent e1100dc commit 6976451
Show file tree
Hide file tree
Showing 4 changed files with 486 additions and 13 deletions.
17 changes: 11 additions & 6 deletions WalletWasabi/Helpers/Guard.cs
Expand Up @@ -113,38 +113,43 @@ public static string NotNullOrEmptyOrWhitespace(string parameterName, string val
}
}

public static int MinimumAndNotNull(string parameterName, int? value, int smallest)
public static T MinimumAndNotNull<T>(string parameterName, T value, T smallest) where T : IComparable
{
NotNull(parameterName, value);

if (value < smallest)
if (value.CompareTo(smallest) < 0)
{
throw new ArgumentOutOfRangeException(parameterName, value, $"Parameter cannot be less than {smallest}.");
}

return (int)value;
return value;
}

public static int MaximumAndNotNull(string parameterName, int? value, int greatest)
public static T MaximumAndNotNull<T>(string parameterName, T value, T greatest) where T : IComparable
{
NotNull(parameterName, value);

if (value > greatest)
if (value.CompareTo(greatest) > 0)
{
throw new ArgumentOutOfRangeException(parameterName, value, $"Parameter cannot be greater than {greatest}.");
}

return (int)value;
return value;
}

public static T InRangeAndNotNull<T>(string parameterName, T value, T smallest, T greatest) where T : IComparable
{
NotNull(parameterName, value);

if (value.CompareTo(smallest) < 0)
{
throw new ArgumentOutOfRangeException(parameterName, value, $"Parameter cannot be less than {smallest}.");
}

if (value.CompareTo(greatest) > 0)
{
throw new ArgumentOutOfRangeException(parameterName, value, $"Parameter cannot be greater than {greatest}.");
}

return value;
}
Expand Down
8 changes: 2 additions & 6 deletions WalletWasabi/Services/IndexDownloader.cs
Expand Up @@ -211,35 +211,31 @@ public void Synchronize(TimeSpan requestInterval)
{
filtersResponse = await WasabiClient.GetFiltersAsync(BestKnownFilter.BlockHash, 1000, Cancel.Token).WithAwaitCancellationAsync(Cancel.Token, 300);
// NOT GenSocksServErr
BackendStatus = BackendStatus.Connected;
TorStatus = TorStatus.Running;
DoNotGenSocksServFail();
}
catch (ConnectionException ex)
{
TorStatus = TorStatus.NotRunning;
BackendStatus = BackendStatus.NotConnected;
HandleIfGenSocksServFail(ex);
throw;
}
catch (TorSocks5FailureResponseException ex)
{
TorStatus = TorStatus.Running;
BackendStatus = BackendStatus.NotConnected;
HandleIfGenSocksServFail(ex);
throw;
}
catch (Exception ex)
{
TorStatus = TorStatus.Running;
BackendStatus = BackendStatus.Connected;
HandleIfGenSocksServFail(ex);
throw;
}
BackendStatus = BackendStatus.Connected;
TorStatus = TorStatus.Running;
if (filtersResponse is null) // no-content, we are synced
{
Expand Down

0 comments on commit 6976451

Please sign in to comment.