forked from Qortal/qortal
Started work on architecture-specific lite wallet library loading. Paths are not yet correct.
This commit is contained in:
parent
f14b494bfc
commit
5203742b05
@ -42,8 +42,12 @@
|
|||||||
|
|
||||||
package com.rust.litewalletjni;
|
package com.rust.litewalletjni;
|
||||||
|
|
||||||
public class LiteWalletJni
|
import org.apache.logging.log4j.LogManager;
|
||||||
{
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public class LiteWalletJni {
|
||||||
|
|
||||||
|
protected static final Logger LOGGER = LogManager.getLogger(LiteWalletJni.class);
|
||||||
|
|
||||||
public static native String initlogging();
|
public static native String initlogging();
|
||||||
public static native String initnew(final String serveruri, final String params, final String saplingOutputb64, final String saplingSpendb64);
|
public static native String initnew(final String serveruri, final String params, final String saplingOutputb64, final String saplingSpendb64);
|
||||||
@ -57,8 +61,42 @@ public class LiteWalletJni
|
|||||||
public static native String checkseedphrase(final String input);
|
public static native String checkseedphrase(final String input);
|
||||||
|
|
||||||
|
|
||||||
static {
|
private static boolean loaded = false;
|
||||||
System.loadLibrary("litewallet-jni");
|
|
||||||
|
public static void loadLibrary() {
|
||||||
|
if (loaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String osName = System.getProperty("os.name");
|
||||||
|
String osArchitecture = System.getProperty("os.arch");
|
||||||
|
|
||||||
|
LOGGER.info("OS Name: {}", osName);
|
||||||
|
LOGGER.info("OS Architecture: {}", osArchitecture);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String libPath;
|
||||||
|
|
||||||
|
if (osName.equals("Mac OS X") && osArchitecture.equals("x86_64")) {
|
||||||
|
libPath = "librust.dylib";
|
||||||
|
}
|
||||||
|
else if (osName.equals("Linux") && osArchitecture.equals("arm")) {
|
||||||
|
libPath = "/home/pi/librust.so";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOGGER.info("Library not found for OS: {}, arch: {}", osName, osArchitecture);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.load(libPath);
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
catch (UnsatisfiedLinkError e) {
|
||||||
|
LOGGER.info("Unable to load library");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLoaded() {
|
||||||
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ public class PirateChainWalletController extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Thread.currentThread().setName("Pirate Chain Wallet Controller");
|
Thread.currentThread().setName("Pirate Chain Wallet Controller");
|
||||||
|
|
||||||
|
LiteWalletJni.loadLibrary();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (running && !Controller.isStopping()) {
|
while (running && !Controller.isStopping()) {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
@ -155,8 +157,8 @@ public class PirateChainWalletController extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ensureInitialized() throws ForeignBlockchainException {
|
public void ensureInitialized() throws ForeignBlockchainException {
|
||||||
if (this.currentWallet == null || !this.currentWallet.isInitialized()) {
|
if (!LiteWalletJni.isLoaded() || this.currentWallet == null || !this.currentWallet.isInitialized()) {
|
||||||
throw new ForeignBlockchainException("Unable to initialize Pirate wallet");
|
throw new ForeignBlockchainException("Pirate wallet isn't initialized yet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user