org.fisco.bcos.channel.handler.GroupChannelConnectionsConfig Java Examples
The following examples show how to use
org.fisco.bcos.channel.handler.GroupChannelConnectionsConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Web3Config.java From WeBASE-Front with Apache License 2.0 | 6 votes |
/** * get a new config instance * @return */ private GroupChannelConnectionsConfig getGroupChannelConnectionsConfig() { List<ChannelConnections> channelConnectionsList = new ArrayList<>(); List<String> connectionsList = new ArrayList<>(); connectionsList.add(ip + ":" + channelPort); log.info("*****" + ip + ":" + channelPort); ChannelConnections channelConnections = new ChannelConnections(); channelConnections.setConnectionsStr(connectionsList); channelConnections.setGroupId(independentGroupId); channelConnectionsList.add(channelConnections); GroupChannelConnectionsConfig groupChannelConnectionsConfig = new GroupChannelConnectionsConfig(); groupChannelConnectionsConfig.setAllChannelConnections(channelConnectionsList); return groupChannelConnectionsConfig; }
Example #2
Source File: Web3Config.java From WeBASE-Front with Apache License 2.0 | 6 votes |
/** * init Web3j of default group id 1 */ @Bean public Web3j getWeb3j(GroupChannelConnectionsConfig groupChannelConnectionsConfig) throws Exception { Service service = new Service(); service.setOrgID(orgName); service.setGroupId(independentGroupId); service.setThreadPool(sdkThreadPool()); service.setAllChannelConnections(groupChannelConnectionsConfig); service.run(); ChannelEthereumService channelEthereumService = new ChannelEthereumService(); channelEthereumService.setTimeout(timeout); channelEthereumService.setChannelService(service); Web3j web3j = Web3j.build(channelEthereumService, service.getGroupId()); // init node version NodeVersion version = web3j.getNodeVersion().send(); Constants.version = version.getNodeVersion().getVersion(); Constants.chainId = version.getNodeVersion().getChainID(); log.info("Chain's clientVersion:{}", Constants.version); return web3j; }
Example #3
Source File: Web3jV2BeanConfig.java From WeBASE-Collect-Bee with Apache License 2.0 | 5 votes |
@Bean public Service getService() { GroupChannelConnectionsConfig groupChannelConnectionsConfig = getGroupChannelConnections(); Service channelService = new Service(); channelService.setGroupId(systemEnvironmentConfig.getGroupId()); channelService.setAllChannelConnections(groupChannelConnectionsConfig); // set some default connect timeout seconds channelService.setConnectSeconds(20); channelService.setConnectSleepPerMillis(10); return channelService; }
Example #4
Source File: Web3jV2BeanConfig.java From WeBASE-Collect-Bee with Apache License 2.0 | 5 votes |
@Bean public GroupChannelConnectionsConfig getGroupChannelConnections() { GroupChannelConnectionsConfig groupChannelConnectionsConfig = new GroupChannelConnectionsConfig(); ChannelConnections con = new ChannelConnections(); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource ca = resolver.getResource("file:./config/ca.crt"); Resource nodeCrt = resolver.getResource("file:./config/node.crt"); Resource nodeKey = resolver.getResource("file:./config/node.key"); groupChannelConnectionsConfig.setCaCert(ca); groupChannelConnectionsConfig.setSslCert(nodeCrt); groupChannelConnectionsConfig.setSslKey(nodeKey); ArrayList<String> list = new ArrayList<>(); List<ChannelConnections> allChannelConnections = new ArrayList<>(); String[] nodes = StringUtils.split(systemEnvironmentConfig.getNodeStr(), ";"); for (int i = 0; i < nodes.length; i++) { if (nodes[i].contains("@")) { nodes[i] = StringUtils.substringAfter(nodes[i], "@"); } } List<String> nodesList = Lists.newArrayList(nodes); list.addAll(nodesList); list.stream().forEach(s -> { log.info("connect address: {}", s); }); con.setConnectionsStr(list); con.setGroupId(systemEnvironmentConfig.getGroupId()); allChannelConnections.add(con); groupChannelConnectionsConfig.setAllChannelConnections(allChannelConnections); return groupChannelConnectionsConfig; }
Example #5
Source File: Web3SDKConnector.java From WeEvent with Apache License 2.0 | 5 votes |
public static Service initService(Long groupId, FiscoConfig fiscoConfig) throws BrokerException { log.info("begin to initialize web3sdk's Service, group id: {}", groupId); try { int web3sdkTimeout = fiscoConfig.getWeb3sdkTimeout(); Service service = new Service(); // change jdk.tls.namedGroups will cause https's bug: ERR_SSL_VERSION_OR_CIPHER_MISMATCH service.setSetJavaOpt(false); // group info service.setOrgID(fiscoConfig.getOrgId()); service.setGroupId(groupId.intValue()); service.setConnectSeconds(web3sdkTimeout / 1000); // reconnect idle time 100ms service.setConnectSleepPerMillis(100); // connect key and string GroupChannelConnectionsConfig connectionsConfig = new GroupChannelConnectionsConfig(); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); connectionsConfig.setCaCert(resolver.getResource("classpath:" + fiscoConfig.getCaCrtPath())); connectionsConfig.setSslCert(resolver.getResource("classpath:" + fiscoConfig.getSdkCrtPath())); connectionsConfig.setSslKey(resolver.getResource("classpath:" + fiscoConfig.getSdkKeyPath())); ChannelConnections channelConnections = new ChannelConnections(); channelConnections.setGroupId(groupId.intValue()); channelConnections.setConnectionsStr(Arrays.asList(fiscoConfig.getNodes().split(";"))); connectionsConfig.setAllChannelConnections(Collections.singletonList(channelConnections)); service.setAllChannelConnections(connectionsConfig); return service; } catch (Exception e) { log.error("init web3sdk's Service failed", e); throw new BrokerException(ErrorCode.WEB3SDK_INIT_SERVICE_ERROR); } }
Example #6
Source File: Service.java From web3sdk with Apache License 2.0 | 4 votes |
public GroupChannelConnectionsConfig getAllChannelConnections() { return allChannelConnections; }
Example #7
Source File: Service.java From web3sdk with Apache License 2.0 | 4 votes |
public void setAllChannelConnections(GroupChannelConnectionsConfig allChannelConnections) { this.allChannelConnections = allChannelConnections; }
Example #8
Source File: Web3Config.java From WeBASE-Front with Apache License 2.0 | 2 votes |
/** * singleton instance of config * @case1: if add new web3j in web3jmap, add connection to channelConnectionsList of this bean * @case2: if create a brand new web3j of new connections config, * use getGroupChannelConnectionsConfig method to create new config * @return */ @Bean public GroupChannelConnectionsConfig initGroupChannelConnectionsConfig() { return getGroupChannelConnectionsConfig(); }