Search in sources :

Example 1 with WebSocketMessageHandler

use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler in project besu by hyperledger.

the class EthSubscribeIntegrationTest method before.

@Before
public void before() {
    vertx = Vertx.vertx();
    subscriptionManager = new SubscriptionManager(new NoOpMetricsSystem());
    webSocketMethodsFactory = new WebSocketMethodsFactory(subscriptionManager, new HashMap<>());
    webSocketMessageHandler = new WebSocketMessageHandler(vertx, new JsonRpcExecutor(new BaseJsonRpcProcessor(), webSocketMethodsFactory.methods()), Mockito.mock(EthScheduler.class), TimeoutOptions.defaultOptions().getTimeoutSeconds());
}
Also used : BaseJsonRpcProcessor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor) HashMap(java.util.HashMap) WebSocketMessageHandler(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) SubscriptionManager(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.SubscriptionManager) JsonRpcExecutor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor) Before(org.junit.Before)

Example 2 with WebSocketMessageHandler

use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler in project besu by hyperledger.

the class EthUnsubscribeIntegrationTest method before.

@Before
public void before() {
    vertx = Vertx.vertx();
    subscriptionManager = new SubscriptionManager(new NoOpMetricsSystem());
    webSocketMethodsFactory = new WebSocketMethodsFactory(subscriptionManager, new HashMap<>());
    webSocketMessageHandler = new WebSocketMessageHandler(vertx, new JsonRpcExecutor(new BaseJsonRpcProcessor(), webSocketMethodsFactory.methods()), mock(EthScheduler.class), TimeoutOptions.defaultOptions().getTimeoutSeconds());
}
Also used : BaseJsonRpcProcessor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor) HashMap(java.util.HashMap) WebSocketMessageHandler(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) SubscriptionManager(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.SubscriptionManager) JsonRpcExecutor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor) Before(org.junit.Before)

Example 3 with WebSocketMessageHandler

use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler in project besu by hyperledger.

the class RunnerBuilder method createWebsocketService.

private WebSocketService createWebsocketService(final Vertx vertx, final WebSocketConfiguration configuration, final SubscriptionManager subscriptionManager, final Map<String, JsonRpcMethod> jsonRpcMethods, final PrivacyParameters privacyParameters, final ProtocolSchedule protocolSchedule, final BlockchainQueries blockchainQueries, final Optional<AuthenticationService> authenticationService, final ObservableMetricsSystem metricsSystem) {
    final WebSocketMethodsFactory websocketMethodsFactory = new WebSocketMethodsFactory(subscriptionManager, jsonRpcMethods);
    if (privacyParameters.isEnabled()) {
        final PrivateWebSocketMethodsFactory privateWebSocketMethodsFactory = new PrivateWebSocketMethodsFactory(privacyParameters, subscriptionManager, protocolSchedule, blockchainQueries);
        privateWebSocketMethodsFactory.methods().forEach(websocketMethodsFactory::addMethods);
    }
    rpcEndpointServiceImpl.getPluginMethods(configuration.getRpcApis()).values().forEach(websocketMethodsFactory::addMethods);
    final JsonRpcProcessor jsonRpcProcessor;
    if (authenticationService.isPresent()) {
        jsonRpcProcessor = new AuthenticatedJsonRpcProcessor(new BaseJsonRpcProcessor(), authenticationService.get(), configuration.getRpcApisNoAuth());
    } else {
        jsonRpcProcessor = new BaseJsonRpcProcessor();
    }
    final JsonRpcExecutor jsonRpcExecutor = new JsonRpcExecutor(jsonRpcProcessor, websocketMethodsFactory.methods());
    final WebSocketMessageHandler websocketMessageHandler = new WebSocketMessageHandler(vertx, jsonRpcExecutor, besuController.getProtocolManager().ethContext().getScheduler(), webSocketConfiguration.getTimeoutSec());
    return new WebSocketService(vertx, configuration, websocketMessageHandler, authenticationService, metricsSystem);
}
Also used : BaseJsonRpcProcessor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor) WebSocketMessageHandler(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler) JsonRpcProcessor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcProcessor) BaseJsonRpcProcessor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor) AuthenticatedJsonRpcProcessor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.AuthenticatedJsonRpcProcessor) WebSocketService(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketService) WebSocketMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketMethodsFactory) PrivateWebSocketMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.PrivateWebSocketMethodsFactory) PrivateWebSocketMethodsFactory(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.PrivateWebSocketMethodsFactory) AuthenticatedJsonRpcProcessor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.AuthenticatedJsonRpcProcessor) JsonRpcExecutor(org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor)

Aggregations

BaseJsonRpcProcessor (org.hyperledger.besu.ethereum.api.jsonrpc.execution.BaseJsonRpcProcessor)3 JsonRpcExecutor (org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcExecutor)3 WebSocketMessageHandler (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketMessageHandler)3 HashMap (java.util.HashMap)2 SubscriptionManager (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.SubscriptionManager)2 NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)2 Before (org.junit.Before)2 AuthenticatedJsonRpcProcessor (org.hyperledger.besu.ethereum.api.jsonrpc.execution.AuthenticatedJsonRpcProcessor)1 JsonRpcProcessor (org.hyperledger.besu.ethereum.api.jsonrpc.execution.JsonRpcProcessor)1 WebSocketService (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketService)1 PrivateWebSocketMethodsFactory (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.PrivateWebSocketMethodsFactory)1 WebSocketMethodsFactory (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketMethodsFactory)1