From 31aca8a800eebbef83187d4cea0e8152c0096692 Mon Sep 17 00:00:00 2001 From: Nathanial Woolls Date: Sun, 1 Mar 2015 13:36:18 -0500 Subject: [PATCH] Fix an InvalidOperationException downloading required miners --- MultiMiner.Engine/MinerFactory.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MultiMiner.Engine/MinerFactory.cs b/MultiMiner.Engine/MinerFactory.cs index d36a8136f..914994fea 100644 --- a/MultiMiner.Engine/MinerFactory.cs +++ b/MultiMiner.Engine/MinerFactory.cs @@ -43,11 +43,16 @@ public MinerDescriptor GetMiner(DeviceKind deviceKind, CoinAlgorithm algorithm, string algorithmName = algorithm.Name; + MinerDescriptor result = null; + if (miners.ContainsKey(algorithmName)) - return Miners.Single(m => m.Name.Equals(miners[algorithmName], StringComparison.OrdinalIgnoreCase)); - if (algorithm.DefaultMiner != null) - return Miners.Single(m => m.Name.Equals(algorithm.DefaultMiner, StringComparison.OrdinalIgnoreCase)); - return null; + // SingleOrDefault - the user may have a config file with a backend + // miner registered that no longer exists in their Miners\ folder + result = Miners.SingleOrDefault(m => m.Name.Equals(miners[algorithmName], StringComparison.OrdinalIgnoreCase)); + if ((result == null) && (algorithm.DefaultMiner != null)) + result = Miners.Single(m => m.Name.Equals(algorithm.DefaultMiner, StringComparison.OrdinalIgnoreCase)); + + return result; } public MinerDescriptor GetMiner(DeviceKind deviceKind, string algorithmName, SerializableDictionary miners)