| | |
| | | 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; |
| | |
| | | |
| | | @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(); |
| | | } |
| | | } |
| | | // 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(); |
| | | // } |
| | | // } |
| | | } |
| | | } |