Skip to content

Commit

Permalink
Merge pull request #2665 from nicehash/master_localPluginVersions
Browse files Browse the repository at this point in the history
Local plugin versions prioritized
  • Loading branch information
S74nk0 authored Apr 20, 2022
2 parents b2d7518 + 4d33fc5 commit ebaca06
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Miners/Excavator/ExcavatorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ExcavatorPlugin()
};
PluginMetaInfo = new PluginMetaInfo
{
PluginDescription = "Excavator NVIDIA GPU miner from NiceHash",
PluginDescription = "Excavator NVIDIA/AMD GPU miner from NiceHash",
SupportedDevicesAlgorithms = SupportedDevicesAlgorithmsDict()
};
}
Expand Down
1 change: 1 addition & 0 deletions src/NHM.MinerPluginToolkitV1/Checkers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static bool IsGcn2(AMDDevice dev)
}

private static int[] _supportedMajorVersions = new int[] { 16, 17 };
public static int GetLatestSupportedVersion => _supportedMajorVersions.Max();
public static IEnumerable<int> SupportedMajorVersions => _supportedMajorVersions;
public static bool IsMajorVersionSupported(int major) => _supportedMajorVersions.Contains(major);

Expand Down
18 changes: 18 additions & 0 deletions src/NHMCore/Mining/Plugins/MinerPluginsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,11 @@ private static void CrossReferenceInstalledWithOnlineEthlargementIntegratedPlugi
}
}

private static string ConstructLocalPluginDescription(PluginBase plugin)
{
var binVersion = plugin.GetMinerBinaryVersion();
return $"Miner Binary Version '{binVersion}'.\n\n" + plugin.GetPluginMetaInfo().PluginDescription;
}
public static void CrossReferenceInstalledWithOnline()
{
// EthlargementIntegratedPlugin special case
Expand All @@ -687,6 +692,19 @@ public static void CrossReferenceInstalledWithOnline()
PluginVersion = installed.Version,
// other stuff is not inside the plugin
};
if (installed.GetPlugin() is PluginBase pb)
{
localPluginInfo.MinerPackageURL = pb.GetMinerBinsUrlsForPlugin().FirstOrDefault();
localPluginInfo.PluginDescription = ConstructLocalPluginDescription(pb);
localPluginInfo.SupportedDevicesAlgorithms = new Dictionary<string, List<string>>();
localPluginInfo.PackagePassword = pb.BinsPackagePassword;
var supportedList = pb.SupportedDevicesAlgorithmsDict();
foreach (var supported in supportedList)
{
var algos = supported.Value.Select(algo => Enum.GetName(typeof(AlgorithmType), algo)).ToList();
localPluginInfo.SupportedDevicesAlgorithms.Add(Enum.GetName(typeof(DeviceType), supported.Key), algos);
}
}
if (PluginsPackagesInfosCRs.ContainsKey(uuid) == false)
{
PluginsPackagesInfosCRs[uuid] = new PluginPackageInfoCR(uuid);
Expand Down
4 changes: 4 additions & 0 deletions src/NHMCore/Mining/Plugins/PluginContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public bool Enabled
// algos for NiceHashMiner Client
private Dictionary<string, List<AlgorithmContainer>> _cachedNiceHashMinerAlgorithms { get; } = new Dictionary<string, List<AlgorithmContainer>>();

public IMinerPlugin GetPlugin()
{
return _plugin;
}
public bool InitPluginContainer()
{
if (IsInitialized) return true;
Expand Down
43 changes: 32 additions & 11 deletions src/NHMCore/Mining/Plugins/PluginPackageInfoCR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public bool Installed

public bool Supported => OnlineSupportedDeviceCount > 0;

public PluginPackageInfo GetInfoSource()
{
if (OnlineInfo?.PluginVersion != null &&
LocalInfo?.PluginVersion != null &&
LocalInfo?.PluginVersion > OnlineInfo?.PluginVersion)
{
return LocalInfo;
}
return OnlineInfo;
}
// for plugins that we provide we can know what versions are and are not supported
public bool CompatibleNHPluginVersion
{
Expand All @@ -106,6 +116,20 @@ public bool CompatibleNHPluginVersion
}
}

public string CompatibilityIssueMessage
{
get
{
if (!CompatibleNHPluginVersion)
{
var ver = OnlineInfo?.PluginVersion ?? null;
if (ver == null) return string.Empty;
var maxVersion = Checkers.GetLatestSupportedVersion;
return ver.Major > maxVersion ? "Please update NiceHash Miner" : "Plugin not compatible";
}
return string.Empty;
}
}
// PluginPackageInfo region
public string PluginUUID
{
Expand All @@ -120,7 +144,7 @@ public string PluginPackageHash
{
get
{
var hash = LocalInfo?.PluginPackageHash ?? OnlineInfo?.PluginPackageHash ?? "N/A";
var hash = OnlineInfo?.PluginPackageHash ?? "N/A";
return hash;
}
}
Expand All @@ -129,7 +153,7 @@ public string BinaryPackageHash
{
get
{
var hash = LocalInfo?.BinaryPackageHash ?? OnlineInfo?.BinaryPackageHash ?? "N/A";
var hash = OnlineInfo?.BinaryPackageHash ?? "N/A";
return hash;
}
}
Expand All @@ -148,7 +172,7 @@ public Version PluginVersion
{
get
{
var ver = LocalInfo?.PluginVersion ?? OnlineInfo?.PluginVersion ?? new Version(0, 0);
var ver = GetInfoSource()?.PluginVersion ?? new Version(0, 0);
return ver;
}
}
Expand All @@ -157,8 +181,7 @@ public string PluginPackageURL
{
get
{
//var pluginURL = LocalInfo?.PluginPackageURL ?? OnlineInfo?.PluginPackageURL ?? "N/A";
var pluginURL = OnlineInfo?.PluginPackageURL ?? "N/A";
var pluginURL = GetInfoSource()?.PluginPackageURL ?? "N/A";
return pluginURL;
}
}
Expand All @@ -167,8 +190,7 @@ public string MinerPackageURL
{
get
{
//var minerURL = LocalInfo?.MinerPackageURL ?? OnlineInfo?.MinerPackageURL ?? "N/A";
var minerURL = OnlineInfo?.MinerPackageURL ?? "N/A";
var minerURL = GetInfoSource()?.MinerPackageURL ?? "N/A";
return minerURL;
}
}
Expand All @@ -177,7 +199,7 @@ public Dictionary<string, List<string>> SupportedDevicesAlgorithms
{
get
{
var supportedDevicesAlgorithms = LocalInfo?.SupportedDevicesAlgorithms ?? OnlineInfo?.SupportedDevicesAlgorithms ?? new Dictionary<string, List<string>>();
var supportedDevicesAlgorithms = GetInfoSource()?.SupportedDevicesAlgorithms ?? new Dictionary<string, List<string>>();
var keysWithNoAlgorithms = supportedDevicesAlgorithms
.Where(pair => !pair.Value.Any())
.Select(pair => pair.Key)
Expand All @@ -192,7 +214,7 @@ public string PluginAuthor
{
get
{
var author = LocalInfo?.PluginAuthor ?? OnlineInfo?.PluginAuthor ?? "N/A";
var author = GetInfoSource()?.PluginAuthor ?? "N/A";
return author;
}
}
Expand All @@ -202,8 +224,7 @@ public string PluginDescription
{
get
{
// prefer local over online
var desc = LocalInfo?.PluginDescription ?? OnlineInfo?.PluginDescription ?? "N/A";
var desc = GetInfoSource()?.PluginDescription ?? "N/A";
return desc;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/NiceHashMiner/ViewModels/Plugins/PluginEntryVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public string InstallVersionStatus
}
if (Plugin.Installed && !Plugin.HasNewerVersion && localVer != null && onlineVer != null)
{
if(localVer > onlineVer) return Tr("{0}.{1} (Latest)", localVer.Major, localVer.Minor);
return Tr("{0}.{1} (Latest)", onlineVer.Major, onlineVer.Minor);
}
if (localVer != null)
Expand Down
2 changes: 1 addition & 1 deletion src/NiceHashMiner/Views/Plugins/PluginItem/PluginItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
FontSize="12"
Margin="0,0,16,0"
Visibility="{Binding Plugin.CompatibleNHPluginVersion, Converter={StaticResource NulBoolToVisibilityConverterFalse}}"
Text="NOT COMPATIBLE. Update NiceHash Miner" />
Text="{Binding Plugin.CompatibilityIssueMessage}" />


</WrapPanel>
Expand Down

0 comments on commit ebaca06

Please sign in to comment.