mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
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:
parent
9ae1a29f23
commit
0e779a4bf6
2 changed files with 12 additions and 9 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue