Search in sources :

Example 1 with ConsensusType

use of org.hyperledger.besu.tests.acceptance.dsl.transaction.bft.ConsensusType in project besu by hyperledger.

the class BesuNode method nodeRequests.

private NodeRequests nodeRequests() {
    Optional<WebSocketService> websocketService = Optional.empty();
    if (nodeRequests == null) {
        final Web3jService web3jService;
        if (useWsForJsonRpc) {
            final String url = wsRpcBaseUrl().orElse("ws://" + LOCALHOST + ":" + 8546);
            final Map<String, String> headers = new HashMap<>();
            if (token != null) {
                headers.put("Authorization", "Bearer " + token);
            }
            final WebSocketClient wsClient = new WebSocketClient(URI.create(url), headers);
            web3jService = new WebSocketService(wsClient, false);
            try {
                ((WebSocketService) web3jService).connect();
            } catch (final ConnectException e) {
                throw new RuntimeException(e);
            }
            websocketService = Optional.of((WebSocketService) web3jService);
        } else {
            final String url = jsonRpcBaseUrl().orElse(HTTP + LOCALHOST + ":" + 8545);
            web3jService = new HttpService(url);
            if (token != null) {
                ((HttpService) web3jService).addHeader("Authorization", "Bearer " + token);
            }
        }
        final ConsensusType bftType = getGenesisConfig().map(gc -> gc.toLowerCase().contains("ibft") ? ConsensusType.IBFT2 : ConsensusType.QBFT).orElse(ConsensusType.IBFT2);
        nodeRequests = new NodeRequests(new JsonRpc2_0Web3j(web3jService, 2000, Async.defaultExecutorService()), new CliqueRequestFactory(web3jService), new BftRequestFactory(web3jService, bftType), new PermissioningJsonRpcRequestFactory(web3jService), new AdminRequestFactory(web3jService), new PrivacyRequestFactory(web3jService), new CustomRequestFactory(web3jService), new MinerRequestFactory(web3jService), new TxPoolRequestFactory(web3jService), websocketService, loginRequestFactory());
    }
    return nodeRequests;
}
Also used : KeyPairUtil(org.hyperledger.besu.crypto.KeyPairUtil) Collections.unmodifiableList(java.util.Collections.unmodifiableList) ConsensusType(org.hyperledger.besu.tests.acceptance.dsl.transaction.bft.ConsensusType) PermissioningConfiguration(org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration) LoggerFactory(org.slf4j.LoggerFactory) WebSocketService(org.web3j.protocol.websocket.WebSocketService) WebSocketConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration) Transaction(org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction) NetworkName(org.hyperledger.besu.cli.config.NetworkName) Map(java.util.Map) Web3jService(org.web3j.protocol.Web3jService) TxPoolRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.txpool.TxPoolRequestFactory) GenesisConfigurationProvider(org.hyperledger.besu.tests.acceptance.dsl.node.configuration.genesis.GenesisConfigurationProvider) URI(java.net.URI) Path(java.nio.file.Path) WebSocketClient(org.web3j.protocol.websocket.WebSocketClient) MinerRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.miner.MinerRequestFactory) NetworkingConfiguration(org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration) Files.copyResource(org.apache.tuweni.io.file.Files.copyResource) MiningParameters(org.hyperledger.besu.ethereum.core.MiningParameters) ConditionTimeoutException(org.awaitility.core.ConditionTimeoutException) PrivacyRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory) List(java.util.List) Optional(java.util.Optional) WebsocketNotConnectedException(org.java_websocket.exceptions.WebsocketNotConnectedException) Awaitility(org.awaitility.Awaitility) Condition(org.hyperledger.besu.tests.acceptance.dsl.condition.Condition) CliqueRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.clique.CliqueRequestFactory) HttpService(org.web3j.protocol.http.HttpService) Async(org.web3j.utils.Async) HashMap(java.util.HashMap) Address(org.hyperledger.besu.datatypes.Address) Util(org.hyperledger.besu.ethereum.core.Util) TLSConfiguration(org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration) ArrayList(java.util.ArrayList) AdminRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.admin.AdminRequestFactory) LoginRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.login.LoginRequestFactory) JsonRpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration) ConnectException(java.net.ConnectException) BftRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.bft.BftRequestFactory) Properties(java.util.Properties) Logger(org.slf4j.Logger) JsonRpc2_0Web3j(org.web3j.protocol.core.JsonRpc2_0Web3j) Files(java.nio.file.Files) MoreObjects(com.google.common.base.MoreObjects) NodeConfiguration(org.hyperledger.besu.tests.acceptance.dsl.node.configuration.NodeConfiguration) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) RecursiveDeleteOption(com.google.common.io.RecursiveDeleteOption) MetricsConfiguration(org.hyperledger.besu.metrics.prometheus.MetricsConfiguration) PermissioningJsonRpcRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningJsonRpcRequestFactory) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) WebSocketListener(org.web3j.protocol.websocket.WebSocketListener) JsonRpcIpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration) KeyPair(org.hyperledger.besu.crypto.KeyPair) MoreFiles(com.google.common.io.MoreFiles) CustomRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.net.CustomRequestFactory) PrivacyParameters(org.hyperledger.besu.ethereum.core.PrivacyParameters) PkiKeyStoreConfiguration(org.hyperledger.besu.pki.config.PkiKeyStoreConfiguration) NodeRequests(org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests) HashMap(java.util.HashMap) NodeRequests(org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests) PrivacyRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyRequestFactory) CliqueRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.clique.CliqueRequestFactory) WebSocketClient(org.web3j.protocol.websocket.WebSocketClient) BftRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.bft.BftRequestFactory) TxPoolRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.txpool.TxPoolRequestFactory) ConsensusType(org.hyperledger.besu.tests.acceptance.dsl.transaction.bft.ConsensusType) HttpService(org.web3j.protocol.http.HttpService) AdminRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.admin.AdminRequestFactory) Web3jService(org.web3j.protocol.Web3jService) CustomRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.net.CustomRequestFactory) MinerRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.miner.MinerRequestFactory) WebSocketService(org.web3j.protocol.websocket.WebSocketService) JsonRpc2_0Web3j(org.web3j.protocol.core.JsonRpc2_0Web3j) PermissioningJsonRpcRequestFactory(org.hyperledger.besu.tests.acceptance.dsl.transaction.perm.PermissioningJsonRpcRequestFactory) ConnectException(java.net.ConnectException)

Aggregations

MoreObjects (com.google.common.base.MoreObjects)1 MoreFiles (com.google.common.io.MoreFiles)1 RecursiveDeleteOption (com.google.common.io.RecursiveDeleteOption)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 URI (java.net.URI)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Collections.unmodifiableList (java.util.Collections.unmodifiableList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Properties (java.util.Properties)1 TimeUnit (java.util.concurrent.TimeUnit)1 Files.copyResource (org.apache.tuweni.io.file.Files.copyResource)1 Awaitility (org.awaitility.Awaitility)1