Release Vexta CPU Miner v0.1.2
This commit is contained in:
parent
17949bc516
commit
d3b9876b45
3 changed files with 399 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -9,6 +10,51 @@ namespace Vexta.CpuMiner;
|
|||
|
||||
public static unsafe class VextaRandomX
|
||||
{
|
||||
private static IntPtr nativeLibraryHandle = IntPtr.Zero;
|
||||
|
||||
public static string? NativeLibraryPath { get; private set; }
|
||||
|
||||
public static bool NativeLibraryLoaded => nativeLibraryHandle != IntPtr.Zero;
|
||||
|
||||
static VextaRandomX()
|
||||
{
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
var libraryPath = Path.Combine(AppContext.BaseDirectory, "librandomx.so");
|
||||
|
||||
if(!File.Exists(libraryPath))
|
||||
throw new DllNotFoundException(
|
||||
$"RandomX library was not found at '{libraryPath}'.");
|
||||
|
||||
try
|
||||
{
|
||||
nativeLibraryHandle = NativeLibrary.Load(libraryPath);
|
||||
NativeLibraryPath = libraryPath;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw new DllNotFoundException(
|
||||
$"Unable to load RandomX library from '{libraryPath}': {ex.Message}",
|
||||
ex);
|
||||
}
|
||||
|
||||
NativeLibrary.SetDllImportResolver(
|
||||
typeof(VextaRandomX).Assembly,
|
||||
(libraryName, assembly, searchPath) =>
|
||||
{
|
||||
if(string.Equals(
|
||||
libraryName,
|
||||
"librandomx",
|
||||
StringComparison.Ordinal))
|
||||
{
|
||||
return nativeLibraryHandle;
|
||||
}
|
||||
|
||||
return IntPtr.Zero;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum RandomXFlags
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue