Helius
2020-10-13 e27a19c86366eeddb98f36d266bbdb220e0ce457
src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtErc20UpdateService.java
@@ -20,7 +20,9 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class UsdtErc20UpdateService {
@@ -88,8 +90,10 @@
        Credentials credentials = Credentials.create(privateKey);
        EthUsdtContract contract = EthUsdtContract.load(contractAddr, getInstance(), credentials, getStaticGasProvider());
        EthFilter filter = getFilter(blockNum);
        Map<String,BigInteger> map = new HashMap<String,BigInteger>();
        map.put("blockNum",blockNum);
        contract.transferEventFlowable(filter).subscribe(e->{
            if(e!=null && StringUtils.isNotBlank(e.to)){
            if(e!=null && StringUtils.isNotBlank(e.to) &&  e.log.getBlockNumber()!=null){
                String transactionHash = e.log.getTransactionHash();
                BigInteger blockNumber1 = e.log.getBlockNumber();
                String toAddress = e.to;
@@ -102,13 +106,16 @@
                    EthUsdtChargeDto dto = new EthUsdtChargeDto(toAddress,transactionHash,divide);
                    usdtUpdateProducer.sendMsg(JSONObject.toJSONString(dto));
                }
                redisUtils.set(USDT_BLOCK_NUM_GOLDEN,blockNumber1.toString());
                if(map.get("blockNum").compareTo(blockNumber1)!=0){
                    redisUtils.set(USDT_BLOCK_NUM_GOLDEN,blockNumber1.toString());
                    map.put("blockNum",blockNumber1);
                }
            }
        });
    }
    private static EthFilter getFilter(BigInteger startBlock) {
        if (startBlock != null) {
            EthFilter filter = new EthFilter(new DefaultBlockParameterNumber(startBlock),