| | |
| | | import cc.mrbird.febs.mall.chain.enums.ChainEnum; |
| | | import cc.mrbird.febs.mall.chain.enums.EthService; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alipay.api.java_websocket.enums.ReadyState; |
| | | import io.reactivex.Flowable; |
| | | import io.reactivex.disposables.Disposable; |
| | | import io.reactivex.schedulers.Schedulers; |
| | |
| | | Web3j web3j = Web3j.build(ws); |
| | | |
| | | EthUsdtContract ethUsdtContract = wssContract(chain.getPrivateKey(), chain.getContractAddress(), web3j); |
| | | |
| | | |
| | | while (!webSocketClient.getReadyState().equals(ReadyState.OPEN)) { |
| | | log.info("连接中···请稍后"); |
| | | } |
| | | |
| | | EthFilter filter = getFilter(startBlock, startBlock, chain.getContractAddress()); |
| | | Flowable<EthUsdtContract.TransferEventResponse> eventFlowable = ethUsdtContract.transferEventFlowable(filter); |
| | | while (!webSocketClient.getReadyState().equals(ReadyState.OPEN)) { |
| | | log.info("连接中···请稍后"); |
| | | } |
| | | // 判断websocket是否连接成功 |
| | | if (!webSocketClient.isOpen()) { |
| | | log.error("WebSocket连接失败"); |
| | | wssContractEventListener2(startBlock, event, type); |
| | | return; |
| | | } |
| | | // 订阅事件流,将事件编译和处理放到单独的线程中执行 |