Skip to content
Permalink
Browse files

Disable peer discovery if cache exists

  • Loading branch information...
lontivero committed Nov 24, 2018
1 parent fa7e72a commit 702c98f3a8aa246a3c05e022af9e74c962553958
Showing with 5 additions and 1 deletion.
  1. +5 −1 WalletWasabi.Gui/Global.cs
@@ -140,6 +140,7 @@ public static void InitializeNoWallet()

Logger.LogInfo<TorProcessManager>($"{nameof(TorProcessManager)} is initialized.");

var needsToDiscoverPeers = true;
if (Network == Network.RegTest)
{
AddressManager = new AddressManager();
@@ -150,6 +151,7 @@ public static void InitializeNoWallet()
try
{
AddressManager = AddressManager.LoadPeerFile(AddressManagerFilePath);
needsToDiscoverPeers = AddressManager.Count < 200;
Logger.LogInfo<AddressManager>($"Loaded {nameof(AddressManager)} from `{AddressManagerFilePath}`.");
}
catch (DirectoryNotFoundException ex)
@@ -184,7 +186,9 @@ public static void InitializeNoWallet()
}
}

connectionParameters.TemplateBehaviors.Add(new AddressManagerBehavior(AddressManager));
var addressManagerBehavior = new AddressManagerBehavior(AddressManager);
addressManagerBehavior.Mode = needsToDiscoverPeers ? AddressManagerBehaviorMode.Discover : AddressManagerBehaviorMode.None;
connectionParameters.TemplateBehaviors.Add(addressManagerBehavior);
MemPoolService = new MemPoolService();
connectionParameters.TemplateBehaviors.Add(new MemPoolBehavior(MemPoolService));

0 comments on commit 702c98f

Please sign in to comment.
You can’t perform that action at this time.