Commit 01679829 authored by jianhua.zhang's avatar jianhua.zhang

切换成中追地址抓取数据,调整接口前缀

parent bcec3b74
......@@ -55,7 +55,7 @@ public class Constant {
/**
* 数据同步阀值
*/
public static final long THRESHOLD = 30000;
public static final long THRESHOLD = 10000;
/**
* 用户地址长度
......
......@@ -127,10 +127,10 @@ public class Engine {
/*
合约事件数据抓取、处理
*/
this.contractEventHandler = new ContractEventHandler();
/*this.contractEventHandler = new ContractEventHandler();
this.contractEventFetcher = new ContractEventFetcher<>(this.contractEventHandler);
this.executor.execute(this.contractEventFetcher);
this.executor.execute(this.contractEventHandler);
this.executor.execute(this.contractEventHandler);*/
}
......
......@@ -2,6 +2,7 @@ package com.wuban.tron.explore.service;
import com.alibaba.fastjson.JSON;
import com.wuban.tron.explore.constant.Constant;
import com.wuban.tron.explore.util.OkHttpClientObject;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Value;
......@@ -19,7 +20,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public abstract class BaseCommonService {
private static final String PREFIX = "/walletsolidity";
private static final String PREFIX = "/wallet";
/**
* 按照高度查询block API
......@@ -37,8 +38,6 @@ public abstract class BaseCommonService {
*/
protected static final String GET_ACCOUNT = PREFIX + "/getaccount";
protected static final String FREEZE_BALANCE = "/wallet/freezebalance";
/**
* 事件日志API
*/
......@@ -49,6 +48,8 @@ public abstract class BaseCommonService {
*/
protected static final String GET_CONTRACT = "/wallet/getcontract";
private final OkHttpClient client = OkHttpClientObject.CLIENT.getClientInstance();
@Value("${tron.site}")
private String tronSite;
......@@ -67,12 +68,7 @@ public abstract class BaseCommonService {
String str = null;
try {
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient
.newBuilder()
.connectTimeout(1, TimeUnit.SECONDS)
.readTimeout(2, TimeUnit.SECONDS);
response = okHttpClient.newCall(executeRequest).execute();
response = client.newCall(executeRequest).execute();
ResponseBody body = response.body();
if (response.code() == Constant.SUCCESS_CODE && body != null) {
str = body.string();
......
package com.wuban.tron.explore.util;
import okhttp3.OkHttpClient;
import java.util.concurrent.TimeUnit;
/**
* Description :
* 获取okHttpClient单例
* @author : Jeason
* @date : Created in 2018/10/25 11:16
*/
public enum OkHttpClientObject {
CLIENT;
private OkHttpClient clientInstance;
private Integer connectTimeout_time = 5;
private Integer writeTimeout_time = 5;
private Integer readTimeout_time = 5;
OkHttpClientObject() {
clientInstance = new OkHttpClient.Builder()
.connectTimeout(connectTimeout_time, TimeUnit.SECONDS)
.writeTimeout(writeTimeout_time, TimeUnit.SECONDS)
.readTimeout(readTimeout_time, TimeUnit.SECONDS)
.retryOnConnectionFailure(true)
.build();
}
public OkHttpClient getClientInstance() {
return clientInstance;
}
}
\ No newline at end of file
# config
tron:
site: https://api.shasta.trongrid.io
site: http://123.57.69.71:26667
#site: https://api.shasta.trongrid.io
contract:
complier:
......
package com.wuban.tron.explore.service.impl;
import com.wuban.tron.explore.domain.*;
import com.wuban.tron.explore.entity.Contract;
import com.wuban.tron.explore.entity.ContractEvent;
import com.wuban.tron.explore.service.ContractEventService;
import com.wuban.tron.explore.service.TronService;
......@@ -32,7 +33,7 @@ class TronServiceImplTest {
@Test
void getBlockByNum() {
TronResponseData data = this.tronService.getBlockByNum(850000L);
TronResponseData data = this.tronService.getBlockByNum(1L);
log.info(data.toString());
}
......@@ -63,10 +64,18 @@ class TronServiceImplTest {
@Test
void getContract() {
String base58check = "TTfwGdf3v66CaYQijg4Qb2CFtdgQnkkFko";
String base58check = "TC2G9UXR8xt6Qg7i4efKe1fMahdgZCQb4e";
String hexString = ByteArray.toHexString(WalletApi.decodeFromBase58Check(base58check));
System.out.println(hexString);
this.tronService.getContract(hexString);
Contract contract = this.tronService.getContract(hexString);
System.out.println(contract.toString());
}
@Test
void test() {
String str = "4181f7e0f75501194bb82e55a896afb6e802ebd42e";
String base58 = WalletApi.encode58Check(ByteArray.fromHexString(str));
System.out.println(base58);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment