Add check if rpc is used

This commit is contained in:
Manfred Karrer 2017-04-10 13:38:26 -05:00
parent 30df6f9721
commit 1d53055e2c
2 changed files with 7 additions and 3 deletions

View file

@ -65,6 +65,7 @@ public class BsqBlockchainManager {
// new snapshot is block 90. We only persist at the new snapshot, so we always re-parse from latest snapshot after
// a restart.
private static final int SNAPSHOT_TRIGGER = 300000;
private final boolean connectToBtcCore;
public static int getSnapshotTrigger() {
return SNAPSHOT_TRIGGER;
@ -97,6 +98,7 @@ public class BsqBlockchainManager {
BisqEnvironment bisqEnvironment,
@Named(Storage.DIR_KEY) File storageDir,
Storage<PlainTextWrapper> jsonStorage,
@Named(RpcOptionKeys.RPC_USER) String rpcUser,
@Named(RpcOptionKeys.DUMP_BLOCKCHAIN_DATA) boolean dumpBlockchainData) {
this.blockchainService = blockchainService;
this.storageDir = storageDir;
@ -104,6 +106,7 @@ public class BsqBlockchainManager {
this.dumpBlockchainData = dumpBlockchainData;
this.bitcoinNetwork = bisqEnvironment.getBitcoinNetwork();
connectToBtcCore = rpcUser != null && !rpcUser.isEmpty();
bsqUTXOMap = new BsqUTXOMap(storageDir);
bsqTXOMap = new BsqTXOMap(storageDir);
@ -212,7 +215,8 @@ public class BsqBlockchainManager {
///////////////////////////////////////////////////////////////////////////////////////////
public void onAllServicesInitialized(ErrorMessageHandler errorMessageHandler) {
blockchainService.setup(this::blockchainServiceSetupCompleted, errorMessageHandler);
if (connectToBtcCore)
blockchainService.setup(this::blockchainServiceSetupCompleted, errorMessageHandler);
}
public Set<String> getUtxoTxIdSet() {

View file

@ -119,7 +119,7 @@ public class BsqBlockchainRpcService extends BsqBlockchainService {
} catch (Throwable e) {
log.error(e.toString());
e.printStackTrace();
throw new BsqBlockchainException(e.getMessage(), e);
throw new BsqBlockchainException(e.toString(), e);
}
});
@ -134,7 +134,7 @@ public class BsqBlockchainRpcService extends BsqBlockchainService {
public void onFailure(@NotNull Throwable throwable) {
UserThread.execute(() -> {
log.error(throwable.toString());
errorMessageHandler.handleErrorMessage(throwable.getMessage());
errorMessageHandler.handleErrorMessage(throwable.toString());
});
}
});