ability to get Auto thingy in gprc

This commit is contained in:
KewbitXMR 2024-09-28 15:11:47 +01:00
parent 11c0f7613b
commit 931d1b7766
4 changed files with 29 additions and 1 deletions

View File

@ -247,6 +247,10 @@ public class CoreApi {
xmrConnectionService.setAutoSwitch(autoSwitch);
}
public boolean getXmrConnectionAutoSwitch() {
return xmrConnectionService.getAutoSwitch();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Monero node
///////////////////////////////////////////////////////////////////////////////////////////

View File

@ -349,6 +349,11 @@ public final class XmrConnectionService {
connectionList.setAutoSwitch(autoSwitch);
}
public boolean getAutoSwitch() {
accountService.checkAccountOpen();
return connectionManager.getAutoSwitch();
}
public boolean isConnectionLocalHost() {
return isConnectionLocalHost(getConnection());
}
@ -596,7 +601,7 @@ public final class XmrConnectionService {
} else if (!isInitialized) {
// set connection from startup argument if given
connectionManager.setAutoSwitch(false);
connectionManager.setAutoSwitch(true);
MoneroRpcConnection connection = new MoneroRpcConnection(config.xmrNode, config.xmrNodeUsername, config.xmrNodePassword).setPriority(1);
if (isProxyApplied(connection)) connection.setProxyUri(getProxyUri());
connectionManager.setConnection(connection);

View File

@ -55,6 +55,8 @@ import haveno.proto.grpc.RemoveConnectionReply;
import haveno.proto.grpc.RemoveConnectionRequest;
import haveno.proto.grpc.SetAutoSwitchReply;
import haveno.proto.grpc.SetAutoSwitchRequest;
import haveno.proto.grpc.GetAutoSwitchRequest;
import haveno.proto.grpc.GetAutoSwitchReply;
import haveno.proto.grpc.SetConnectionReply;
import haveno.proto.grpc.SetConnectionRequest;
import haveno.proto.grpc.StartCheckingConnectionReply;
@ -221,6 +223,15 @@ class GrpcXmrConnectionService extends XmrConnectionsImplBase {
});
}
@Override
public void getAutoSwitch(GetAutoSwitchRequest request,
StreamObserver<GetAutoSwitchReply> responseObserver) {
handleRequest(responseObserver, () -> {
coreApi.getXmrConnectionAutoSwitch();
return GetAutoSwitchReply.newBuilder().build();
});
}
private <_Reply> void handleRequest(StreamObserver<_Reply> responseObserver,
RpcRequestHandler<_Reply> handler) {
try {

View File

@ -323,6 +323,8 @@ service XmrConnections {
}
rpc SetAutoSwitch(SetAutoSwitchRequest) returns (SetAutoSwitchReply) {
}
rpc GetAutoSwitch(GetAutoSwitchRequest) returns (GetAutoSwitchRequest) {
}
}
message UrlConnection {
@ -410,6 +412,12 @@ message SetAutoSwitchRequest {
message SetAutoSwitchReply {}
message GetAutoSwitchRequest {}
message GetAutoSwitchReply {
bool auto_switch = 1;
}
///////////////////////////////////////////////////////////////////////////////////////////
// XmrNode
///////////////////////////////////////////////////////////////////////////////////////////