Helius
2022-06-01 abf16ade315ba2626339713e798d87eba336c37f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cc.mrbird.febs.job;
 
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.common.utils.RedisUtils;
import cc.mrbird.febs.dapp.chain.ChainEnum;
import cc.mrbird.febs.dapp.chain.ChainService;
import cc.mrbird.febs.dapp.chain.ContractEventService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.math.BigInteger;
 
@Slf4j
@Component
public class ChainListenerJob {
 
    @Autowired
    private ContractEventService bscCoinContractEvent;
 
    @Autowired
    private ContractEventService bscUsdtContractEvent;
 
    @Autowired
    private RedisUtils redisUtils;
 
    @PostConstruct
    public void chainListenerJob() {
        log.info("监听打开");
        BigInteger usdtBlock;
        BigInteger coinBlock;
        Object usdt = redisUtils.get(AppContants.REDIS_KEY_BLOCK_USDT_NUM);
        if (usdt == null) {
            usdtBlock = new BigInteger("19811973");
        } else {
            usdtBlock = (BigInteger) usdt;
        }
 
        Object coin = redisUtils.get(AppContants.REDIS_KEY_BLOCK_COIN_NUM);
        if (coin == null) {
            coinBlock = new BigInteger("19811973");
        } else {
            coinBlock = (BigInteger) coin;
        }
 
        ChainService.contractEventListener(usdtBlock, bscUsdtContractEvent, ChainEnum.BSC_USDT.name());
        ChainService.contractEventListener(coinBlock, bscCoinContractEvent, ChainEnum.BSC_TFC.name());
    }
}