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

波场浏览器JAVA版

parent 48b2532a
......@@ -70,7 +70,7 @@ public class Bootstrapper {
private long getInitialDelay() {
Date nextDate = DateUtil.addDays(new Date(), 1);
String date = DateUtil.getFormatDate(nextDate, DateUtil.PATTERN_YMD) + " 00:00:03";
long millis = (DateUtil.getDateFromDateStr(date) - System.currentTimeMillis())/1000;
long millis = (DateUtil.getDateFromDateStr(date, DateUtil.PATTERN_YMD_HMS) - System.currentTimeMillis())/1000;
return millis;
}
......
package com.wuban.tron.explore.constant;
import okhttp3.MediaType;
import org.springframework.beans.factory.annotation.Value;
/**
* <core>常量定义类</core>
......@@ -45,7 +46,7 @@ public class Constant {
/**
* 用户地址长度
*/
public static final int USER_ADDRESS_LEN = 42;
public static final int USER_ADDRESS_LEN = 34;
/**
* txID长度
......
......@@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* <core>区块统计API</core>
......@@ -26,9 +29,11 @@ public class CensusController {
private final TransactionService transactionService;
private final ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
@RequestMapping(method = RequestMethod.POST)
public void census(@RequestBody @Valid CensusRequest reqParam) {
new Thread(()->this.transactionService.censusBlockByDate(reqParam.getStartDate(), reqParam.getEndDate())).start();
this.pool.execute(() -> this.transactionService.censusBlockByDate(reqParam.getStartDate(), reqParam.getEndDate()));
}
}
package com.wuban.tron.explore.dao;
import com.wuban.tron.explore.entity.BlockHeader;
import com.wuban.tron.explore.entity.Transaction;
import com.wuban.tron.explore.entity.example.BlockHeaderExample;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -46,4 +47,12 @@ public interface BlockHeaderRepository {
*/
BlockHeader selectOneByExample(@Param("example")BlockHeaderExample example);
/**
* 分页查询
*
* @param example 查询条件参数
* @return 分页记录列表
*/
List<BlockHeader> selectByPagerEx(@Param("example") BlockHeaderExample example);
}
......@@ -59,4 +59,15 @@ public interface TransactionRepository {
*/
List<Transaction> selectListByAddress(@Param("address") String address, @Param("t") long timestamp);
/**
* 根据账户地址查询交易信息
*
* @param address 账户地址
*
*
* @return
*/
List<Transaction> selectPageByAddress(@Param("address") String address);
}
......@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Slf4j
public class Executor {
private static final int SIZE = 10;
private static final int SIZE = 15;
private final List<AbstractJob> jobList = new ArrayList<>();
private final String name;
private ThreadPoolExecutor pool;
......
......@@ -8,6 +8,8 @@ import com.wuban.tron.explore.service.AddressService;
import com.wuban.tron.explore.util.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.tron.common.utils.ByteArray;
import org.tron.walletserver.WalletApi;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -53,7 +55,9 @@ public class AddressBalanceHandler extends AbstractJob implements IAddressBalanc
public void flush(List<TronAccount> e) {
if (!CollectionUtils.isEmpty(e)) {
Address obj = new Address();
obj.setAddress(e.get(0).getAddress());
String address = WalletApi.encode58Check(ByteArray.fromHexString(e.get(0).getAddress()));
obj.setAddress(address);
obj.setBalance(e.get(0).getBalance());
this.addressService.updateById(obj);
log.info("更新账户余额 account:{}", obj.toString());
......
package com.wuban.tron.explore.param.response;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class AccountInfoModel {
private String address;
private String balance;
private String more_info;
private String name;
private String tag;
private String creator;
private String hash;
private String type;
private int txn_count;
public static AccountInfoModel getInstance() {
return AccountInfoModel.builder()
.address("")
.balance("")
.more_info("")
.name("")
.tag("")
.creator("")
.hash("")
.type("")
.txn_count(0)
.build();
}
}
package com.wuban.tron.explore.param.response;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class AddessInfoModel {
private String address;
private String balance;
private String more_info;
private String name;
private String tag;
private String creator;
private String hash;
private String type;
private int txn_count;
public static AddessInfoModel getInstance() {
return AddessInfoModel.builder()
.address("")
.balance("")
.more_info("")
.name("")
.tag("")
.creator("")
.hash("")
.type("")
.txn_count(0)
.build();
}
}
package com.wuban.tron.explore.param.response;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.wuban.tron.explore.entity.Transaction;
import lombok.Builder;
import lombok.Data;
import java.util.Date;
/**
* 区块详情MODEL
*
* @author wuban-team
* @date 2020-11-16
*/
@Data
@Builder
public class BlockInfoModel {
private long number;
private String timestamp;
private String miner;
private String mined_time;
private String block_reward;
private String uncles_reward;
private String difficulty;
private String totalDifficulty;
private String size;
private String extraData;
private String hash;
private String mixHash;
private String parentHash;
private String sha3Uncles;
private String stateRoot;
private String receiptsRoot;
private String transactionsRoot;
private String nonce;
private String gasUsed;
private String gasLimit;
@JsonProperty(value="Transaction")
private Object transaction;
private int trans_number;
public static BlockInfoModel getInstance() {
return BlockInfoModel.builder()
.number(0L)
.timestamp("")
.miner("")
.mined_time("")
.block_reward("")
.uncles_reward("")
.difficulty("")
.totalDifficulty("")
.size("")
.extraData("")
.hash("")
.mixHash("")
.parentHash("")
.sha3Uncles("")
.stateRoot("")
.receiptsRoot("")
.transactionsRoot("")
.nonce("")
.gasUsed("")
.gasLimit("")
.build();
}
}
package com.wuban.tron.explore.param.response;
import lombok.Data;
@Data
public class HomeChartModel {
private int id;
private long time;
private int count;
}
package com.wuban.tron.explore.param.response;
import lombok.Data;
/**
* 统一响应数据MODEL
*
* @author wuban-team
* @date 2020-11-16
*/
@Data
public class ResDataModel<T> {
private int total;
private int sum;
private int t;
private long total_balance;
private Object data;
}
package com.wuban.tron.explore.param.response;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;
/**
* 交易详情MODEL
*
* @author wuban-team
* @date 2020-11-16
*/
@Data
@Builder
public class TransInfoModel {
private String hash;
private String blockHash;
@JsonProperty(value="BlockNumber")
private Object blockNumber;
private String timestamp;
private String from;
private String to;
private String value;
private String v;
private String gas;
private String gasPrice;
private String transactionIndex;
private String nonce;
private String input;
public static TransInfoModel getInstance() {
return TransInfoModel.builder()
.hash("")
.blockHash("")
.blockNumber(0)
.timestamp("")
.from("")
.to("")
.value("")
.v("")
.gas("")
.gasPrice("")
.transactionIndex("")
.nonce("")
.input("")
.blockNumber(null)
.build();
}
}
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.wuban.tron.explore.constant.Constant;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Value;
import java.io.IOException;
import java.util.Map;
......@@ -36,6 +37,9 @@ public abstract class BaseCommonService {
*/
protected static final String GET_ACCOUNT = PREFIX + "/getaccount";
@Value("${tron.site}")
private String tronSite;
/**
* http请求
*
......@@ -79,7 +83,7 @@ public abstract class BaseCommonService {
protected Request builder(String uri, Map<String, Object> paramMap) {
String param = JSON.toJSONString(paramMap);
RequestBody postBody = RequestBody.create(param, Constant.JSON_TYPE);
return new Request.Builder().url(Constant.HOST + uri).post(postBody)
return new Request.Builder().url(this.tronSite + uri).post(postBody)
.addHeader(Constant.CONTENT_TYPE_KEY, Constant.CONTENT_TYPE_VAL).build();
}
......
package com.wuban.tron.explore.service;
import com.github.pagehelper.PageInfo;
import com.wuban.tron.explore.entity.BlockHeader;
import com.wuban.tron.explore.entity.example.BlockHeaderExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <core>区块头服务接口</core>
*
......@@ -20,4 +23,14 @@ public interface BlockHeaderService {
*/
BlockHeader getOneByExample(@Param("example") BlockHeaderExample example);
/**
* 分页查询
*
* @param startIndex
* @param pageSize
* @param example 查询条件参数
* @return 分页记录列表
*/
PageInfo<BlockHeader> getByPagerEx(Integer startIndex, Integer pageSize, @Param("example") BlockHeaderExample example);
}
......@@ -77,7 +77,18 @@ public interface TransactionService {
* @param pageSize
* @return
*/
PageInfo<Transaction> selectListByAddress(String address, int type, Integer startIndex, Integer pageSize);
PageInfo<Transaction> selectListByAddress(String address, Integer type, Integer startIndex, Integer pageSize);
/**
* 根据账户地址查询交易信息
*
* @param address 账户地址
* @param startIndex
* @param pageSize
* @return
*/
PageInfo<Transaction> selectPageByAddress(@Param("address") String address, Integer startIndex, Integer pageSize);
}
package com.wuban.tron.explore.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuban.tron.explore.constant.PageConstant;
import com.wuban.tron.explore.dao.BlockHeaderRepository;
import com.wuban.tron.explore.entity.BlockHeader;
import com.wuban.tron.explore.entity.example.BlockHeaderExample;
......@@ -8,6 +11,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <core>区块头服务接口实现类</core>
*
......@@ -31,5 +36,33 @@ public class BlockHeaderServiceImpl implements BlockHeaderService {
return blockHeaderRepository.selectOneByExample(example);
}
/**
* 分页查询
*
* @param example 查询条件参数
* @return 分页记录列表
*/
@Override
public PageInfo<BlockHeader> getByPagerEx(Integer startIndex, Integer pageSize, BlockHeaderExample example) {
if (startIndex == null) {
startIndex = PageConstant.DEFAULT_START_INDEX;
}
if (pageSize == null) {
pageSize = PageConstant.DEFAULT_PAGE_SIZE;
}
if (pageSize > PageConstant.MAX_PAGE_SIZE) {
pageSize = PageConstant.MAX_PAGE_SIZE;
}
example.setOrderByClause("`timestamp` DESC");
PageHelper.startPage(startIndex, pageSize);
List<BlockHeader> list = this.blockHeaderRepository.selectByPagerEx(example);
PageInfo<BlockHeader> pageInfo = new PageInfo<>(list);
return pageInfo;
}
}
......@@ -8,7 +8,6 @@ import com.wuban.tron.explore.dao.*;
import com.wuban.tron.explore.domain.*;
import com.wuban.tron.explore.entity.*;
import com.wuban.tron.explore.entity.example.TransactionExample;
import com.wuban.tron.explore.fetch.Executor;
import com.wuban.tron.explore.service.TransactionService;
import com.wuban.tron.explore.util.BigDecimalUtil;
import com.wuban.tron.explore.util.DateUtil;
......@@ -24,6 +23,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.tron.common.utils.ByteArray;
import org.tron.walletserver.WalletApi;
import java.math.BigDecimal;
import java.math.BigInteger;
......@@ -54,8 +55,6 @@ public class TransactionServiceImpl implements TransactionService {
private final StringRedisTemplate stringRedisTemplate;
private Executor excutor;
@Override
@Transactional(rollbackFor = Exception.class)
public void save(List<TronResponseData> dataList) {
......@@ -103,17 +102,31 @@ public class TransactionServiceImpl implements TransactionService {
区块头、区块交易、hex持久化
*/
this.blockHeaderRepository.batchInsert(headerList);
Set<String> set = new HashSet<>();
Set<String> hexSet = new HashSet<>();
Set<String> base58Set = new HashSet<>();
if (transactionList.size() != 0) {
transactionList.forEach(o -> {
// hex 数据转换成base58
String ownerAddress;
String toAddress;
String contractAddress;
if (!StringUtils.isEmpty(o.getOwnerAddress())) {
set.add(o.getOwnerAddress());
hexSet.add(o.getOwnerAddress());
ownerAddress = WalletApi.encode58Check(ByteArray.fromHexString(o.getOwnerAddress()));
o.setOwnerAddress(ownerAddress);
base58Set.add(ownerAddress);
}
if (!StringUtils.isEmpty(o.getToAddress())) {
set.add(o.getToAddress());
hexSet.add(o.getToAddress());
toAddress = WalletApi.encode58Check(ByteArray.fromHexString(o.getToAddress()));
o.setToAddress(toAddress);
base58Set.add(toAddress);
}
if (!StringUtils.isEmpty(o.getContractAddress())) {
set.add(o.getContractAddress());
hexSet.add(o.getContractAddress());
contractAddress = WalletApi.encode58Check(ByteArray.fromHexString(o.getContractAddress()));
o.setContractAddress(contractAddress);
base58Set.add(contractAddress);
}
});
this.transactionRepository.batchInsert(transactionList);
......@@ -127,12 +140,10 @@ public class TransactionServiceImpl implements TransactionService {
this.lastBlockRepository.updateCurBlockNumById(lastBlock);
log.info("已同步数据区块高度num:{}",headerList.get(0).getNumber());
List<Address> records = transferAddress(set);
List<Address> records = transferAddress(base58Set);
if (!CollectionUtils.isEmpty(records)) {
this.addressRepository.batchInsertOnDuplicateKey(records);
/* AccountBalanceTask task = new AccountBalanceTask(set);
excutor.execute(task);*/
addressPushRedis(set);
addressPushRedis(hexSet);
}
}
......@@ -204,6 +215,7 @@ public class TransactionServiceImpl implements TransactionService {
Contract contract = rawData.getContract().get(0);
ContractParameter contractParameter = contract.getParameter();
ContractParameterValue val = contractParameter.getValue();
Transaction tr = Transaction.builder()
.blockId(blockId)
.txId(o.getTxID())
......@@ -229,13 +241,6 @@ public class TransactionServiceImpl implements TransactionService {
return retList;
}
/*public synchronized void initExcutor() {
if (excutor == null) {
excutor = new Executor(Constant.EXCUTOR_NAME_ACCOUNT, 3);
new AccountBalanceTask();
}
}*/
@Override
public Long getBlockMinTime() {
return this.blockHeaderRepository.selectBlockMinTime();
......@@ -252,6 +257,7 @@ public class TransactionServiceImpl implements TransactionService {
@Override
public void censusBlockByDate(String startDate, String endDate) {
log.info("按天统计交易数据开始startDate:{} 结束endDate:{}", startDate, endDate);
if (StringUtils.isEmpty(endDate) || (startDate.equals(endDate))) {
String _startDate = startDate + " 00:00:00";
String _endDate = startDate + " 23:59:59";
......@@ -263,14 +269,14 @@ public class TransactionServiceImpl implements TransactionService {
while (true) {
String _startDate = date + " 00:00:00";
String _endDate = date + " 23:59:59";
this.census(startDate, _startDate, _endDate);
this.census(date, _startDate, _endDate);
if (date == endDate) {
if (date.equals(endDate)) {
break;
}
Date nextDate = DateUtil.addDays(new Date(), 1);
date = DateUtil.getFormatDate(nextDate,DateUtil.PATTERN_YMD);
Date nextDate = DateUtil.addDays(date, 1);
date = DateUtil.getFormatDate(nextDate, DateUtil.PATTERN_YMD);
}
}
......@@ -316,7 +322,7 @@ public class TransactionServiceImpl implements TransactionService {
}
@Override
public PageInfo<Transaction> selectListByAddress(String address, int type, Integer startIndex, Integer pageSize) {
public PageInfo<Transaction> selectListByAddress(String address, Integer type, Integer startIndex, Integer pageSize) {
Date date;
switch (type) {
case 1:
......@@ -329,10 +335,10 @@ public class TransactionServiceImpl implements TransactionService {
date = DateUtil.addDays(new Date(), -30);
break;
default:
date = DateUtil.addDays(new Date(), -7);
date = null;
}
String str = DateUtil.getFormatDate(date, DateUtil.PATTERN_YMD_HMS);
long t = DateUtil.getDateFromDateStr(str);
long t = DateUtil.getDateFromDateStr(str, DateUtil.PATTERN_YMD_HMS);
if (startIndex == null) {
startIndex = PageConstant.DEFAULT_START_INDEX;
......@@ -353,9 +359,38 @@ public class TransactionServiceImpl implements TransactionService {
return pageInfo;
}
/**
* 根据账户地址查询交易信息
*
* @param address 账户地址
* @param startIndex
* @param pageSize
* @return
*/
@Override
public PageInfo<Transaction> selectPageByAddress(String address, Integer startIndex, Integer pageSize) {
if (startIndex == null) {
startIndex = PageConstant.DEFAULT_START_INDEX;
}
if (pageSize == null) {
pageSize = PageConstant.DEFAULT_PAGE_SIZE;
}
if (pageSize > PageConstant.MAX_PAGE_SIZE) {
pageSize = PageConstant.MAX_PAGE_SIZE;
}
PageHelper.startPage(startIndex, pageSize);
List<Transaction> list = this.transactionRepository.selectPageByAddress(address);
PageInfo<Transaction> pageInfo = new PageInfo<>(list);
return pageInfo;
}
private void census(String date, String startDate, String endDate) {
Long startDateSeconds = DateUtil.getDateFromDateStr(startDate);
Long endDateSeconds = DateUtil.getDateFromDateStr(endDate);
Long startDateSeconds = DateUtil.getDateFromDateStr(startDate, DateUtil.PATTERN_YMD_HMS);
Long endDateSeconds = DateUtil.getDateFromDateStr(endDate, DateUtil.PATTERN_YMD_HMS);
BlockDayCensus data = this.blockDayCensusRepository.censusBlockByTime(startDateSeconds, endDateSeconds);
if (data != null) {
Long totalSeconds = 24 * 60 * 60L;
......@@ -367,6 +402,9 @@ public class TransactionServiceImpl implements TransactionService {
BigDecimal averBlockBytes = BigDecimalUtil.getDevide(new BigDecimal(data.getTotalBlockBytes()), new BigDecimal(data.getGenBlockTotalNum()));
data.setAverBlockBytes(averBlockBytes.intValue());
this.blockDayCensusRepository.insert(data);
log.info("date:{} 交易数据已统计完成",date);
} else {
log.info("date:{} 暂无交易数据统计",date);
}
}
......
......@@ -21,46 +21,36 @@ public class ApiResponse<T> {
public static final String DEFAULT_SUCCESS_MESSAGE = "操作成功";
private Boolean success;
private Integer code;
private String msg;
private Integer error;
private String err_msg;
private T data;
public ApiResponse() {
}
public ApiResponse(Boolean success, Integer code, String message, T data) {
this.success = success;
this.code = code;
this.msg = message;
public ApiResponse(Integer error, String message, T data) {
this.error = error;
this.err_msg = message;
this.data = data;
}
public Boolean getSuccess() {
return success;
public Integer getError() {
return error;
}
public void setSuccess(Boolean success) {
this.success = success;
public void setError(Integer error) {
this.error = error;
}
public Integer getCode() {
return code;
public String getErr_msg() {
return err_msg;
}
public void setCode(Integer code) {
this.code = code;
public void setErr_msg(String err_msg) {
this.err_msg = err_msg;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
public T getData() {
return data;
}
......
......@@ -165,6 +165,31 @@ public class DateUtil {
* @return
*/
public static Date addDays(final Date date, final int days) {
final Calendar cal = Calendar.getInstance();
if (date != null) {
cal.setTime(date);
}
cal.add(0, days);
return cal.getTime();
}
/**
* date 日期加上或减去几天
*
* @param dateStr
* @param days
* @return
*/
public static Date addDays(final String dateStr, final int days) {
Date date;
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
date = format.parse(dateStr);
} catch (ParseException e) {
return null;
}
final Calendar cal = Calendar.getInstance();
if (date != null) {
cal.setTime(date);
......@@ -231,8 +256,8 @@ public class DateUtil {
* @param date
* @return
*/
public static Long getDateFromDateStr(String date) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static Long getDateFromDateStr(String date, String pattern) {
SimpleDateFormat format = new SimpleDateFormat(pattern);
try {
Date dateTime = format.parse(date);
return dateTime.getTime();
......
......@@ -12,11 +12,11 @@ package com.wuban.tron.explore.util;
public class ErrorResponseData extends ApiResponse {
public ErrorResponseData(Integer code, String message) {
super(false, code, message, null);
super(code, message, null);
}
public ErrorResponseData(Integer code, String message, Object object) {
super(false, code, message, object);
super(code, message, object);
}
}
......@@ -12,14 +12,14 @@ package com.wuban.tron.explore.util;
public class SuccessResponseData<T> extends ApiResponse {
public SuccessResponseData() {
super(true, OK, DEFAULT_SUCCESS_MESSAGE, null);
super(OK, DEFAULT_SUCCESS_MESSAGE, null);
}
public SuccessResponseData(T object) {
super(true, OK, DEFAULT_SUCCESS_MESSAGE, object);
super(OK, DEFAULT_SUCCESS_MESSAGE, object);
}
public SuccessResponseData(String message, Object object) {
super(true, OK, message, object);
super(OK, message, object);
}
}
# config
tron:
site: https://api.shasta.trongrid.io
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.56.5.114:13306/test_tron?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root123456
# 初始化大小,最小,最大
initialSize: 20
minIdle: 5
maxActive: 100
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒St
minEvictableIdleTimeMillis: 300000
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
redis:
host: 123.56.5.114
port: 6379
jedis:
pool:
max-active: 1024
max-idle: 200
max-wait: 10000
min-idle: 100
timeout: 10000
password: 123456
database: 2
\ No newline at end of file
# config
tron:
site: https://api.shasta.trongrid.io
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://123.56.5.114:13306/test_tron?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root123456
# 初始化大小,最小,最大
initialSize: 20
minIdle: 5
maxActive: 100
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒St
minEvictableIdleTimeMillis: 300000
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
redis:
host: 123.56.5.114
port: 6379
jedis:
pool:
max-active: 1024
max-idle: 200
max-wait: 10000
min-idle: 100
timeout: 10000
password: 123456
database: 2
\ No newline at end of file
server:
port: 8080
# config
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://coupon-d.mysql.db.wuban.net.cn:30101/tron-explore?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: ^osyBXr7}duMefFb
# 初始化大小,最小,最大
initialSize: 5
minIdle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒St
minEvictableIdleTimeMillis: 300000
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
redis:
host: coupon.redis.db.wuban.net.cn
port: 30104
jedis:
pool:
max-active: 1024
max-idle: 200
max-wait: 10000
min-idle: 100
timeout: 10000
password: lk_2AF|;29l3qvZJ
database: 8
profiles:
active:
- dev
application:
name: tron-explore
mybatis:
mapper-locations: classpath:*.xml
type-aliases-package: com.wuban.tron.explore.entity
logging:
level:
com.wuban.tron.explore.dao: error
\ No newline at end of file
com.wuban.tron.explore.dao: debug
\ No newline at end of file
......@@ -266,4 +266,16 @@
from <include refid="Table_Name"/>
</select>
<select id="selectByPagerEx" resultMap="BlockHeaderMap" parameterType="java.util.Map">
select
<include refid="Base_Column_List"/>
from <include refid="Table_Name"/>
<if test="example != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
</mapper>
......@@ -305,4 +305,12 @@
where (`timestamp` &gt; #{t}) and (owner_address = #{address} or to_address = #{address})
order by `timestamp` desc
</select>
<select id="selectPageByAddress" resultMap="TransactionMap" parameterType="java.util.Map">
select
tx_id,owner_address,contract_address,to_address,`number`,`timestamp`,amount
from <include refid="Table_Name"/>
where (owner_address = #{address} or to_address = #{address} or contract_address= #{address})
order by `timestamp` desc
</select>
</mapper>
......@@ -53,7 +53,7 @@ class BlockHeaderRepositoryTest {
void testDateDely() {
Date nextDate = DateUtil.addDays(new Date(), 1);
String date = DateUtil.getFormatDate(nextDate,"yyyy-MM-dd") + " 00:00:01";
Long millis = (DateUtil.getDateFromDateStr(date) - System.currentTimeMillis())/1000;
Long millis = (DateUtil.getDateFromDateStr(date, DateUtil.PATTERN_YMD_HMS) - System.currentTimeMillis())/1000;
System.out.println(millis+"--------------------");
}
......
......@@ -5,8 +5,6 @@ import com.wuban.tron.explore.entity.Transaction;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.tron.common.utils.ByteArray;
import org.tron.walletserver.WalletApi;
import java.util.List;
......@@ -32,9 +30,9 @@ class TransactionRepositoryTest extends BaseTest {
@Test
void test() {
String hexString = "416c4858d8d3435d278a34146d49dd7e126879ba0d";
/* String hexString = "416c4858d8d3435d278a34146d49dd7e126879ba0d";
String base58check = WalletApi.encode58Check(ByteArray.fromHexString(hexString));
System.out.println(base58check);
System.out.println(base58check);*/
}
}
\ No newline at end of file
......@@ -129,7 +129,7 @@ CREATE TABLE `tron_transaction` (
DROP TABLE IF EXISTS `tron_transaction_hex`;
CREATE TABLE `tron_transaction_hex` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`hex` text COLLATE utf8mb4_unicode_ci,
`hex` longtext COLLATE utf8mb4_unicode_ci,
`block_id` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '区块ID',
`tx_id` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '交易ID',
`signature` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
......
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