mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-22 12:09:22 +00:00
support getting connection auto switch flag from grpc api
get connection auto switch flag from grpc api
This commit is contained in:
parent
a1b50a7b42
commit
ebc28805c8
4 changed files with 29 additions and 0 deletions
|
@ -247,6 +247,10 @@ public class CoreApi {
|
|||
xmrConnectionService.setAutoSwitch(autoSwitch);
|
||||
}
|
||||
|
||||
public boolean getXmrConnectionAutoSwitch() {
|
||||
return xmrConnectionService.getAutoSwitch();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Monero node
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -349,6 +349,11 @@ public final class XmrConnectionService {
|
|||
connectionList.setAutoSwitch(autoSwitch);
|
||||
}
|
||||
|
||||
public boolean getAutoSwitch() {
|
||||
accountService.checkAccountOpen();
|
||||
return connectionList.getAutoSwitch();
|
||||
}
|
||||
|
||||
public boolean isConnectionLocalHost() {
|
||||
return isConnectionLocalHost(getConnection());
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ import haveno.proto.grpc.CheckConnectionReply;
|
|||
import haveno.proto.grpc.CheckConnectionRequest;
|
||||
import haveno.proto.grpc.CheckConnectionsReply;
|
||||
import haveno.proto.grpc.CheckConnectionsRequest;
|
||||
import haveno.proto.grpc.GetAutoSwitchReply;
|
||||
import haveno.proto.grpc.GetAutoSwitchRequest;
|
||||
import haveno.proto.grpc.GetBestAvailableConnectionReply;
|
||||
import haveno.proto.grpc.GetBestAvailableConnectionRequest;
|
||||
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,
|
||||
RpcRequestHandler<_Reply> handler) {
|
||||
try {
|
||||
|
|
|
@ -323,6 +323,8 @@ service XmrConnections {
|
|||
}
|
||||
rpc SetAutoSwitch(SetAutoSwitchRequest) returns (SetAutoSwitchReply) {
|
||||
}
|
||||
rpc GetAutoSwitch(GetAutoSwitchRequest) returns (GetAutoSwitchReply) {
|
||||
}
|
||||
}
|
||||
|
||||
message UrlConnection {
|
||||
|
@ -410,6 +412,12 @@ message SetAutoSwitchRequest {
|
|||
|
||||
message SetAutoSwitchReply {}
|
||||
|
||||
message GetAutoSwitchRequest {}
|
||||
|
||||
message GetAutoSwitchReply {
|
||||
bool auto_switch = 1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// XmrNode
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in a new issue