Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ To include `xdagj-native-randomx` in your project, add the following dependency
<dependency>
<groupId>io.xdag</groupId>
<artifactId>xdagj-native-randomx</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.xdag</groupId>
<artifactId>xdagj-native-randomx</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>

<name>xdagj-native-randomx</name>
<description>A Java RandomX Library For XDAGJ</description>
Expand Down
19 changes: 15 additions & 4 deletions src/main/java/io/xdag/crypto/randomx/RandomXLibraryLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,22 @@ private static File extractAndLoadNativeLibrary() throws IOException, IllegalSta
}

String mappedLibName = System.mapLibraryName(libraryLogicalName);
String tempFilePrefix = mappedLibName.substring(0, mappedLibName.lastIndexOf('.'));
String tempFileSuffix = mappedLibName.substring(mappedLibName.lastIndexOf('.'));
File tempFile;

if (os.contains("win")) {
// Use a fixed file name under Windows: randomx.dll
Path tempDir = Files.createTempDirectory("randomx-");
tempDir.toFile().deleteOnExit();
tempFilePath = tempDir.resolve("randomx.dll"); // Fixed name
} else {
// Linux and macOS uses the default temporary files policy
String tempFilePrefix = mappedLibName.substring(0, mappedLibName.lastIndexOf('.'));
String tempFileSuffix = mappedLibName.substring(mappedLibName.lastIndexOf('.'));
tempFilePath = Files.createTempFile(tempFilePrefix + "-", tempFileSuffix);
}

tempFile = tempFilePath.toFile();

tempFilePath = Files.createTempFile(tempFilePrefix + "-", tempFileSuffix);
File tempFile = tempFilePath.toFile();
tempFile.deleteOnExit();

Files.copy(libStream, tempFilePath, StandardCopyOption.REPLACE_EXISTING);
Expand Down
Binary file modified src/main/resources/native/librandomx_linux_x86_64.so
Binary file not shown.
Binary file modified src/main/resources/native/librandomx_macos_x86_64.dylib
Binary file not shown.
Binary file modified src/main/resources/native/librandomx_windows_x86_64.dll
Binary file not shown.
Loading