Inject CoreContext into server, then set isApiUser=true

Do not set isApiUser=true based on hardcoded thread name ;-(

For requested change
https://github.com/bisq-network/bisq/pull/5065#pullrequestreview-567708569
This commit is contained in:
ghubstan 2021-01-13 19:55:49 -03:00
parent 9ae1a29f23
commit 0e779a4bf6
No known key found for this signature in database
GPG key ID: E35592D6800A861E
2 changed files with 12 additions and 9 deletions

View file

@ -20,20 +20,19 @@ package bisq.core.api;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import static java.lang.Thread.currentThread;
@Singleton
@Slf4j
class CoreContext {
public class CoreContext {
@Getter
@Setter
private boolean isApiUser;
@Inject
public CoreContext() {
}
public boolean isApiUser() {
String threadName = currentThread().getName();
return threadName.equals("BisqDaemonMain") || threadName.contains("grpc");
}
}

View file

@ -17,6 +17,8 @@
package bisq.daemon.grpc;
import bisq.core.api.CoreContext;
import bisq.common.UserThread;
import bisq.common.config.Config;
@ -44,7 +46,8 @@ public class GrpcServer {
private final Server server;
@Inject
public GrpcServer(Config config,
public GrpcServer(CoreContext coreContext,
Config config,
PasswordAuthInterceptor passwordAuthInterceptor,
GrpcDisputeAgentsService disputeAgentsService,
GrpcOffersService offersService,
@ -66,6 +69,7 @@ public class GrpcServer {
.addService(walletsService)
.intercept(passwordAuthInterceptor)
.build();
coreContext.setApiUser(true);
}
public void start() {