Refactor Tor.cs
MODIFY
HiddenWallet.Daemon/Tor.cs
HiddenWallet.Daemon/Tor.cs
@@ -20,7 +20,27 @@ namespace HiddenWallet.Daemon
public static SocksPortHandler SocksPortHandler = new SocksPortHandler("127.0.0.1", socksPort: SOCKSPort);
public static DotNetTor.ControlPort.Client ControlPortClient = new DotNetTor.ControlPort.Client("127.0.0.1", controlPort: ControlPort, password: "ILoveBitcoin21");
public static CancellationTokenSource CircuitEstablishingJobCancel = new CancellationTokenSource();
+
private static TorState _state = TorState.NotStarted;
+ public static TorState State
+ {
+ get { return _state; }
+ set
+ {
+ if (value != _state)
+ {
+ _state = value;
+ try
+ {
+ NotificationBroadcaster.Instance.BroadcastTorState(State.ToString());
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
+ }
+ }
+ }
public static async Task MakeSureCircuitEstablishedAsync()
{
@@ -112,30 +132,5 @@ namespace HiddenWallet.Daemon
EstablishingCircuit,
CircuitEstablished
}
-
- private static void TryBroadcast()
- {
- try
- {
- NotificationBroadcaster.Instance.BroadcastTorState(State.ToString());
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- }
- }
-
- public static TorState State
- {
- get { return _state; }
- set
- {
- if (value != _state)
- {
- _state = value;
- try { TryBroadcast(); } catch { }
- }
- }
- }
}
}

Refactor Tor.cs