本文整理汇总了Java中org.web3j.protocol.ipc.UnixIpcService类的典型用法代码示例。如果您正苦于以下问题:Java UnixIpcService类的具体用法?Java UnixIpcService怎么用?Java UnixIpcService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnixIpcService类属于org.web3j.protocol.ipc包,在下文中一共展示了UnixIpcService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EthereumWeb3jProvider
import org.web3j.protocol.ipc.UnixIpcService; //导入依赖的package包/类
@Inject
public EthereumWeb3jProvider(EthereumConnectorConfig config) {
if (config.getEthereumJsonRpc() == null
&& config.getEthereumIpc() == null
&& config.getInfuraRpc() == null) {
this.web3j = Web3j.build(new HttpService(EthereumConnectorConfig.DEFAULT_JSON_RPC));
} else if (config.getEthereumJsonRpc() != null
&& config.getEthereumIpc() == null
&& config.getInfuraRpc() == null) {
this.web3j = Web3j.build(new HttpService(config.getEthereumJsonRpc()));
} else if (config.getEthereumJsonRpc() == null
&& config.getEthereumIpc() != null
&& config.getInfuraRpc() == null) {
this.web3j = Web3j.build(new UnixIpcService(config.getEthereumIpc()));
} else if (config.getEthereumJsonRpc() == null
&& config.getEthereumIpc() == null
&& config.getInfuraRpc() != null) {
this.web3j = Web3j.build(new InfuraHttpService(config.getInfuraRpc()));
} else {
throw new IllegalArgumentException("More than 1 Ethereum service providers found");
}
}
示例2: ApplicationContext
import org.web3j.protocol.ipc.UnixIpcService; //导入依赖的package包/类
public ApplicationContext(CoreContext context) {
super(context);
this.context = context;
synchronized (ApplicationContext.class) {
if (web == null) {
logger.log("Subscribing to ipc.. " + config.getIpc() + " on " + config.getOs());
if (config.getOs().equals(ApplicationConfig.OSType.WINDOWS)) {
web = Web3j.build(new WindowsIpcService(config.getIpc()));
} else {
web = Web3j.build(new UnixIpcService(config.getIpc()));
}
logger.log("Successfully connected to ipc, waiting for blocks..");
web.ethSyncing().observable().subscribe(is -> {
logger.event("synchronizing").put("is", is.isSyncing()).send();
});
}
}
}
示例3: init
import org.web3j.protocol.ipc.UnixIpcService; //导入依赖的package包/类
private void init() {
if (USING_IPC) {
if (DEBUG) { // IPC Logging
System.setProperty("org.apache.commons.logging.simplelog.log.org.web3j.protocol.ipc", "DEBUG");
}
web3j = Web3j.build(new UnixIpcService(IPC_SOCKET_PATH));
} else {
if (DEBUG) { // HTTP Logging
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.web3j.protocol.ipc", "DEBUG");
}
web3j = Web3j.build(new HttpService(URL_JSON_RPC));
}
subscription = web3j.blockObservable(false).subscribe(block -> {
blockObservable(block);
}, Throwable::printStackTrace, () -> System.out.println("block done"));
web3j.transactionObservable().subscribe(tx -> {
transactionObservable(tx);
}, Throwable::printStackTrace, () -> System.out.println("tx done"));
web3j.pendingTransactionObservable().subscribe(tx -> {
pendingTransactionObservable(tx);
}, Throwable::printStackTrace, () -> System.out.println("ptx done"));
}