| | |
| | | package com.xcong.excoin.quartz.job; |
| | | |
| | | import cn.hutool.http.HttpException; |
| | | import com.xcong.excoin.modules.blackchain.service.TrxUsdtUpdateService; |
| | | import com.xcong.excoin.modules.coin.service.BlockCoinService; |
| | | import com.xcong.excoin.rabbit.producer.UsdtUpdateProducer; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | //@ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true") |
| | | @ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true") |
| | | public class BlockCoinUpdateJob { |
| | | |
| | | @Resource |
| | |
| | | @Resource |
| | | RedisUtils redisUtils; |
| | | |
| | | @Autowired |
| | | private UsdtUpdateProducer usdtUpdateProducer; |
| | | |
| | | |
| | | public static ConcurrentLinkedQueue<Long> TRC_BLOCK = new ConcurrentLinkedQueue<>(); |
| | | |
| | |
| | | * TRC20_USDT 同步 |
| | | */ |
| | | @Scheduled(cron = "0/2 * * * * ? ") |
| | | @Async |
| | | // @Async |
| | | public void usdtTc20Update() { |
| | | // 波场3秒出一个块 |
| | | Long blocnNum = TRC_BLOCK.poll(); |
| | | if (blocnNum == null) { |
| | | return; |
| | | } |
| | | usdtUpdateProducer.sendTrc20BlockMsg(blocnNum.toString()); |
| | | redisUtils.set("USDT_TRC20_CURRENT_BLOCK_NUM", blocnNum); |
| | | try { |
| | | trxUsdtUpdateService.monitorCoinListener(blocnNum); |
| | | } catch (RestClientException e) { |
| | | // 此时是连接问题 这个块需要重新扫描 |
| | | log.info("查询区块超时:" + blocnNum); |
| | | TRC_BLOCK.add(blocnNum); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // try { |
| | | // trxUsdtUpdateService.monitorCoinListener(blocnNum); |
| | | // } catch (RestClientException | HttpException e) { |
| | | // // 此时是连接问题 这个块需要重新扫描 |
| | | // log.info("查询区块超时:" + blocnNum); |
| | | // TRC_BLOCK.add(blocnNum); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | } |
| | | |