support getting connection auto switch flag from grpc api

get connection auto switch flag from grpc api
This commit is contained in:
woodser 2024-10-07 09:21:23 -04:00 committed by GitHub
parent a1b50a7b42
commit ebc28805c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 0 deletions

View file

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

View file

@ -349,6 +349,11 @@ public final class XmrConnectionService {
connectionList.setAutoSwitch(autoSwitch); connectionList.setAutoSwitch(autoSwitch);
} }
public boolean getAutoSwitch() {
accountService.checkAccountOpen();
return connectionList.getAutoSwitch();
}
public boolean isConnectionLocalHost() { public boolean isConnectionLocalHost() {
return isConnectionLocalHost(getConnection()); return isConnectionLocalHost(getConnection());
} }

View file

@ -45,6 +45,8 @@ import haveno.proto.grpc.CheckConnectionReply;
import haveno.proto.grpc.CheckConnectionRequest; import haveno.proto.grpc.CheckConnectionRequest;
import haveno.proto.grpc.CheckConnectionsReply; import haveno.proto.grpc.CheckConnectionsReply;
import haveno.proto.grpc.CheckConnectionsRequest; import haveno.proto.grpc.CheckConnectionsRequest;
import haveno.proto.grpc.GetAutoSwitchReply;
import haveno.proto.grpc.GetAutoSwitchRequest;
import haveno.proto.grpc.GetBestAvailableConnectionReply; import haveno.proto.grpc.GetBestAvailableConnectionReply;
import haveno.proto.grpc.GetBestAvailableConnectionRequest; import haveno.proto.grpc.GetBestAvailableConnectionRequest;
import haveno.proto.grpc.GetConnectionReply; import haveno.proto.grpc.GetConnectionReply;
@ -221,6 +223,16 @@ class GrpcXmrConnectionService extends XmrConnectionsImplBase {
}); });
} }
@Override
public void getAutoSwitch(GetAutoSwitchRequest request,
StreamObserver<GetAutoSwitchReply> responseObserver) {
handleRequest(responseObserver, () -> {
GetAutoSwitchReply.Builder builder = GetAutoSwitchReply.newBuilder();
builder.setAutoSwitch(coreApi.getXmrConnectionAutoSwitch());
return builder.build();
});
}
private <_Reply> void handleRequest(StreamObserver<_Reply> responseObserver, private <_Reply> void handleRequest(StreamObserver<_Reply> responseObserver,
RpcRequestHandler<_Reply> handler) { RpcRequestHandler<_Reply> handler) {
try { try {

View file

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