| | |
| | | }catch (Exception exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | | }); |
| | | }, |
| | | error -> System.out.println("onError: " + error), |
| | | () -> System.out.println("onComplete will not be printed!") |
| | | ); |
| | | } |
| | | |
| | | public void listenBettings(BigInteger startBlock){ |
| | | System.out.println("启动投注监听事件"); |
| | | // 指定密钥文件并进行账号和密码的验证 |
| | | Credentials credentials = Credentials.create(privateKey); |
| | | Abi contract = Abi.load(contractAddr, getInstanceScope(), credentials, new DefaultGasProvider()); |
| | | EthFilter filter = getFilter(startBlock); |
| | | contract.withdrawnEventFlowable(filter).subscribe(e->{ |
| | | try { |
| | | // 更新区块编号 TODO |
| | | if(ObjectUtil.isEmpty(e.log.getBlockNumber())){ |
| | | redisService.set("BNB_BLOCK_NUMBER",startBlock.intValue()); |
| | | }else{ |
| | | redisService.set("BNB_BLOCK_NUMBER",e.log.getBlockNumber().intValue()); |
| | | } |
| | | }catch (Exception exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | | }, |
| | | error -> System.out.println("onError: " + error), |
| | | () -> System.out.println("onComplete will not be printed!") |
| | | ); |
| | | } |
| | | |
| | | /** |