KKSU
2024-05-20 6c5b26120aad4fce252929b9ea7833acce90824c
src/main/java/cc/mrbird/febs/job/ChainHuaDianJob.java
copy from src/main/java/cc/mrbird/febs/job/ChainListenerJob.java copy to src/main/java/cc/mrbird/febs/job/ChainHuaDianJob.java
File was copied from src/main/java/cc/mrbird/febs/job/ChainListenerJob.java
@@ -15,9 +15,9 @@
@Slf4j
@Component
@ConditionalOnProperty(prefix = "system", name = "chain-listener", havingValue = "true")
@ConditionalOnProperty(prefix = "system", name = "huadian-transfer", havingValue = "true")
//public class ChainListenerJob implements ApplicationRunner {
public class ChainListenerJob{
public class ChainHuaDianJob {
    @Autowired
    private ContractEventService bscCoinContractEvent;
@@ -33,35 +33,7 @@
        log.info("最新区块更新");
        BigInteger blockNumber = ChainService.getInstance(ChainEnum.BSC_GFA.name()).blockNumber();
        redisUtils.set(AppContants.REDIS_KEY_BLOCK_ETH_NEWEST_NUM, blockNumber);
        redisUtils.set(AppContants.REDIS_KEY_BLOCK_ETH_NEWEST_NUM_HUA_DIAN, blockNumber);
    }
    @Scheduled(cron = "0/2 * * * * ? ")
    public void chainIncrementBlock() {
        Object newestBlockObj = redisUtils.get(AppContants.REDIS_KEY_BLOCK_ETH_NEWEST_NUM);
        BigInteger newestBlock;
        if (newestBlockObj == null) {
            newestBlock = ChainService.getInstance(ChainEnum.BSC_GFA.name()).blockNumber();
        } else {
            newestBlock = (BigInteger) newestBlockObj;
        }
        Object incrementObj = redisUtils.get(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM);
        BigInteger toIncrement;
        if (incrementObj == null) {
            toIncrement = newestBlock;
        } else {
            BigInteger incrementBlock = (BigInteger) incrementObj;
            // 最新区块小于增加区块
            if (newestBlock.compareTo(incrementBlock) <= 0) {
                return;
            }
            toIncrement = incrementBlock.add(BigInteger.ONE);
        }
        redisUtils.set(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM, toIncrement);
    }
    @Scheduled(cron = "0/2 * * * * ? ")