Helius
2021-05-07 0c3a888e7629749d4c9b9f68273a50e1b6b0c13d
modify
1 files modified
1 files added
60 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/blackchain/service/TrxUsdtUpdateService.java 12 ●●●●● patch | view | raw | blame | history
src/test/java/com/xcong/excoin/TrcTest.java 48 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/blackchain/service/TrxUsdtUpdateService.java
@@ -1,6 +1,8 @@
package com.xcong.excoin.modules.blackchain.service;
import cn.hutool.core.math.MathUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -167,7 +169,8 @@
        Map<String, Object> map = new HashMap<>();
        map.put("num", num);
        String param = JSON.toJSONString(map);
        return postForEntity(url, param).getBody();
//        return postForEntity(url, param).getBody();
        return postForEntityHuTool(url, param).body();
    }
@@ -208,6 +211,13 @@
        return result;
    }
    private static HttpResponse postForEntityHuTool(String url, String param) {
        return HttpUtil.createPost(url).body(param)
                .timeout(20000).contentType("application/json")
                .header("TRON-PRO-API-KEY", Trc20Service.API_KEY)
                .execute();
    }
    /**
     * 比对本地地址 同步充值USDT-TRC20
     *
src/test/java/com/xcong/excoin/TrcTest.java
New file
@@ -0,0 +1,48 @@
package com.xcong.excoin;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.xcong.excoin.modules.blackchain.service.Trc20Service;
import com.xcong.excoin.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
 * @author wzy
 * @date 2021-05-04
 **/
@Slf4j
@SpringBootTest
public class TrcTest {
    @Autowired
    private RedisUtils redisUtils;
    @Test
    public void trc20Test() {
        String url = "https://api.trongrid.io/wallet/getblockbynum";
        while(true) {
            Object current = redisUtils.get("USDT_TRC20_CURRENT_BLOCK_NUM");
            Map<String, Object> map = new HashMap<>();
            map.put("num", current);
            String param = JSON.toJSONString(map);
            System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
            HttpResponse response = HttpUtil.createPost(url).body(param).contentType("application/json").header("TRON-PRO-API-KEY", Trc20Service.API_KEY).execute();
//            log.info(response.body());
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}