xiaoyong931011
2022-12-14 e8e9bae7c0c389a60d8ff16c75edbb35005558d3
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
package cc.mrbird.febs.dapp.contract;
 
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.common.service.RedisService;
import cc.mrbird.febs.dapp.entity.DataDictionaryCustom;
import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum;
import cc.mrbird.febs.dapp.mapper.DataDictionaryCustomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.math.BigInteger;
 
 
@Component
public class ContractInit {
 
    @Autowired
    private ContractMain contractMain;
 
    @Autowired
    private DataDictionaryCustomMapper dataDictionaryCustomMapper;
 
    @Autowired
    private RedisService redisService;
 
 
    @PostConstruct
    public void init(){
        // 设置起始区块编号 TODO
        BigInteger start = new BigInteger("23886625");
        // 需要打开 获取最新区块编号
        Object bnb_block_number = redisService.get("BNB_BLOCK_NUMBER");
        if(bnb_block_number !=null){
            start = BigInteger.valueOf(Long.valueOf(bnb_block_number.toString()));
        }
        DataDictionaryCustom feeAddressKey = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.FEE_ADDRESS_KEY.getType(), DataDictionaryEnum.FEE_ADDRESS_KEY.getCode());
        AppContants.FEE_ADDRESS_KEY.put("feeAddressKey",feeAddressKey.getValue());
        feeAddressKey.setValue("已初始化");
        dataDictionaryCustomMapper.updateById(feeAddressKey);
        System.out.println("启动区块事件监听,监听起始:"+start);
        contractMain.listenBetting(start);
    }
}