Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tron-explore
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张建华@五瓣科技
tron-explore
Commits
dee5d47e
Commit
dee5d47e
authored
Nov 17, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
波场浏览器JAVA版
parent
48b2532a
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
956 additions
and
107 deletions
+956
-107
Bootstrapper.java
src/main/java/com/wuban/tron/explore/Bootstrapper.java
+1
-1
Constant.java
src/main/java/com/wuban/tron/explore/constant/Constant.java
+2
-1
CensusController.java
...a/com/wuban/tron/explore/controller/CensusController.java
+6
-1
TransactionControllerV1.java
...n/tron/explore/controller/v1/TransactionControllerV1.java
+411
-0
BlockHeaderRepository.java
...ava/com/wuban/tron/explore/dao/BlockHeaderRepository.java
+9
-0
TransactionRepository.java
...ava/com/wuban/tron/explore/dao/TransactionRepository.java
+11
-0
Executor.java
src/main/java/com/wuban/tron/explore/fetch/Executor.java
+1
-1
AddressBalanceHandler.java
...com/wuban/tron/explore/handler/AddressBalanceHandler.java
+5
-1
AccountInfoModel.java
...m/wuban/tron/explore/param/response/AccountInfoModel.java
+35
-0
AddessInfoModel.java
...om/wuban/tron/explore/param/response/AddessInfoModel.java
+34
-0
BlockInfoModel.java
...com/wuban/tron/explore/param/response/BlockInfoModel.java
+70
-0
HomeChartModel.java
...com/wuban/tron/explore/param/response/HomeChartModel.java
+12
-0
ResDataModel.java
...a/com/wuban/tron/explore/param/response/ResDataModel.java
+20
-0
TransInfoModel.java
...com/wuban/tron/explore/param/response/TransInfoModel.java
+52
-0
BaseCommonService.java
...ava/com/wuban/tron/explore/service/BaseCommonService.java
+5
-1
BlockHeaderService.java
...va/com/wuban/tron/explore/service/BlockHeaderService.java
+13
-0
TransactionService.java
...va/com/wuban/tron/explore/service/TransactionService.java
+12
-1
BlockHeaderServiceImpl.java
...ban/tron/explore/service/impl/BlockHeaderServiceImpl.java
+33
-0
TransactionServiceImpl.java
...ban/tron/explore/service/impl/TransactionServiceImpl.java
+65
-27
ApiResponse.java
src/main/java/com/wuban/tron/explore/util/ApiResponse.java
+14
-24
DateUtil.java
src/main/java/com/wuban/tron/explore/util/DateUtil.java
+27
-2
ErrorResponseData.java
...n/java/com/wuban/tron/explore/util/ErrorResponseData.java
+2
-2
SuccessResponseData.java
...java/com/wuban/tron/explore/util/SuccessResponseData.java
+3
-3
application-dev.yml
src/main/resources/application-dev.yml
+41
-0
application-test.yml
src/main/resources/application-test.yml
+41
-0
application.yml
src/main/resources/application.yml
+7
-36
BlockHeaderMapper.xml
src/main/resources/mapper/BlockHeaderMapper.xml
+12
-0
TransactionMapper.xml
src/main/resources/mapper/TransactionMapper.xml
+8
-0
BlockHeaderRepositoryTest.java
...com/wuban/tron/explore/dao/BlockHeaderRepositoryTest.java
+1
-1
TransactionRepositoryTest.java
...com/wuban/tron/explore/dao/TransactionRepositoryTest.java
+2
-4
tron-explore.sql
tron-explore.sql
+1
-1
No files found.
src/main/java/com/wuban/tron/explore/Bootstrapper.java
View file @
dee5d47e
...
@@ -70,7 +70,7 @@ public class Bootstrapper {
...
@@ -70,7 +70,7 @@ public class Bootstrapper {
private
long
getInitialDelay
()
{
private
long
getInitialDelay
()
{
Date
nextDate
=
DateUtil
.
addDays
(
new
Date
(),
1
);
Date
nextDate
=
DateUtil
.
addDays
(
new
Date
(),
1
);
String
date
=
DateUtil
.
getFormatDate
(
nextDate
,
DateUtil
.
PATTERN_YMD
)
+
" 00:00:03"
;
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
;
return
millis
;
}
}
...
...
src/main/java/com/wuban/tron/explore/constant/Constant.java
View file @
dee5d47e
package
com
.
wuban
.
tron
.
explore
.
constant
;
package
com
.
wuban
.
tron
.
explore
.
constant
;
import
okhttp3.MediaType
;
import
okhttp3.MediaType
;
import
org.springframework.beans.factory.annotation.Value
;
/**
/**
* <core>常量定义类</core>
* <core>常量定义类</core>
...
@@ -45,7 +46,7 @@ public class Constant {
...
@@ -45,7 +46,7 @@ public class Constant {
/**
/**
* 用户地址长度
* 用户地址长度
*/
*/
public
static
final
int
USER_ADDRESS_LEN
=
42
;
public
static
final
int
USER_ADDRESS_LEN
=
34
;
/**
/**
* txID长度
* txID长度
...
...
src/main/java/com/wuban/tron/explore/controller/CensusController.java
View file @
dee5d47e
...
@@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
/**
/**
* <core>区块统计API</core>
* <core>区块统计API</core>
...
@@ -26,9 +29,11 @@ public class CensusController {
...
@@ -26,9 +29,11 @@ public class CensusController {
private
final
TransactionService
transactionService
;
private
final
TransactionService
transactionService
;
private
final
ThreadPoolExecutor
pool
=
new
ThreadPoolExecutor
(
1
,
1
,
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>());
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
void
census
(
@RequestBody
@Valid
CensusRequest
reqParam
)
{
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
())
);
}
}
}
}
src/main/java/com/wuban/tron/explore/controller/v1/TransactionControllerV1.java
0 → 100644
View file @
dee5d47e
This diff is collapsed.
Click to expand it.
src/main/java/com/wuban/tron/explore/dao/BlockHeaderRepository.java
View file @
dee5d47e
package
com
.
wuban
.
tron
.
explore
.
dao
;
package
com
.
wuban
.
tron
.
explore
.
dao
;
import
com.wuban.tron.explore.entity.BlockHeader
;
import
com.wuban.tron.explore.entity.BlockHeader
;
import
com.wuban.tron.explore.entity.Transaction
;
import
com.wuban.tron.explore.entity.example.BlockHeaderExample
;
import
com.wuban.tron.explore.entity.example.BlockHeaderExample
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
...
@@ -46,4 +47,12 @@ public interface BlockHeaderRepository {
...
@@ -46,4 +47,12 @@ public interface BlockHeaderRepository {
*/
*/
BlockHeader
selectOneByExample
(
@Param
(
"example"
)
BlockHeaderExample
example
);
BlockHeader
selectOneByExample
(
@Param
(
"example"
)
BlockHeaderExample
example
);
/**
* 分页查询
*
* @param example 查询条件参数
* @return 分页记录列表
*/
List
<
BlockHeader
>
selectByPagerEx
(
@Param
(
"example"
)
BlockHeaderExample
example
);
}
}
src/main/java/com/wuban/tron/explore/dao/TransactionRepository.java
View file @
dee5d47e
...
@@ -59,4 +59,15 @@ public interface TransactionRepository {
...
@@ -59,4 +59,15 @@ public interface TransactionRepository {
*/
*/
List
<
Transaction
>
selectListByAddress
(
@Param
(
"address"
)
String
address
,
@Param
(
"t"
)
long
timestamp
);
List
<
Transaction
>
selectListByAddress
(
@Param
(
"address"
)
String
address
,
@Param
(
"t"
)
long
timestamp
);
/**
* 根据账户地址查询交易信息
*
* @param address 账户地址
*
*
* @return
*/
List
<
Transaction
>
selectPageByAddress
(
@Param
(
"address"
)
String
address
);
}
}
src/main/java/com/wuban/tron/explore/fetch/Executor.java
View file @
dee5d47e
...
@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
...
@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Slf4j
@Slf4j
public
class
Executor
{
public
class
Executor
{
private
static
final
int
SIZE
=
1
0
;
private
static
final
int
SIZE
=
1
5
;
private
final
List
<
AbstractJob
>
jobList
=
new
ArrayList
<>();
private
final
List
<
AbstractJob
>
jobList
=
new
ArrayList
<>();
private
final
String
name
;
private
final
String
name
;
private
ThreadPoolExecutor
pool
;
private
ThreadPoolExecutor
pool
;
...
...
src/main/java/com/wuban/tron/explore/handler/AddressBalanceHandler.java
View file @
dee5d47e
...
@@ -8,6 +8,8 @@ import com.wuban.tron.explore.service.AddressService;
...
@@ -8,6 +8,8 @@ import com.wuban.tron.explore.service.AddressService;
import
com.wuban.tron.explore.util.SpringContextUtil
;
import
com.wuban.tron.explore.util.SpringContextUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.tron.common.utils.ByteArray
;
import
org.tron.walletserver.WalletApi
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
@@ -53,7 +55,9 @@ public class AddressBalanceHandler extends AbstractJob implements IAddressBalanc
...
@@ -53,7 +55,9 @@ public class AddressBalanceHandler extends AbstractJob implements IAddressBalanc
public
void
flush
(
List
<
TronAccount
>
e
)
{
public
void
flush
(
List
<
TronAccount
>
e
)
{
if
(!
CollectionUtils
.
isEmpty
(
e
))
{
if
(!
CollectionUtils
.
isEmpty
(
e
))
{
Address
obj
=
new
Address
();
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
());
obj
.
setBalance
(
e
.
get
(
0
).
getBalance
());
this
.
addressService
.
updateById
(
obj
);
this
.
addressService
.
updateById
(
obj
);
log
.
info
(
"更新账户余额 account:{}"
,
obj
.
toString
());
log
.
info
(
"更新账户余额 account:{}"
,
obj
.
toString
());
...
...
src/main/java/com/wuban/tron/explore/param/response/AccountInfoModel.java
0 → 100644
View file @
dee5d47e
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
();
}
}
src/main/java/com/wuban/tron/explore/param/response/AddessInfoModel.java
0 → 100644
View file @
dee5d47e
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
();
}
}
src/main/java/com/wuban/tron/explore/param/response/BlockInfoModel.java
0 → 100644
View file @
dee5d47e
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
();
}
}
src/main/java/com/wuban/tron/explore/param/response/HomeChartModel.java
0 → 100644
View file @
dee5d47e
package
com
.
wuban
.
tron
.
explore
.
param
.
response
;
import
lombok.Data
;
@Data
public
class
HomeChartModel
{
private
int
id
;
private
long
time
;
private
int
count
;
}
src/main/java/com/wuban/tron/explore/param/response/ResDataModel.java
0 → 100644
View file @
dee5d47e
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
;
}
src/main/java/com/wuban/tron/explore/param/response/TransInfoModel.java
0 → 100644
View file @
dee5d47e
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
();
}
}
src/main/java/com/wuban/tron/explore/service/BaseCommonService.java
View file @
dee5d47e
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.wuban.tron.explore.constant.Constant
;
import
com.wuban.tron.explore.constant.Constant
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.*
;
import
okhttp3.*
;
import
org.springframework.beans.factory.annotation.Value
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -36,6 +37,9 @@ public abstract class BaseCommonService {
...
@@ -36,6 +37,9 @@ public abstract class BaseCommonService {
*/
*/
protected
static
final
String
GET_ACCOUNT
=
PREFIX
+
"/getaccount"
;
protected
static
final
String
GET_ACCOUNT
=
PREFIX
+
"/getaccount"
;
@Value
(
"${tron.site}"
)
private
String
tronSite
;
/**
/**
* http请求
* http请求
*
*
...
@@ -79,7 +83,7 @@ public abstract class BaseCommonService {
...
@@ -79,7 +83,7 @@ public abstract class BaseCommonService {
protected
Request
builder
(
String
uri
,
Map
<
String
,
Object
>
paramMap
)
{
protected
Request
builder
(
String
uri
,
Map
<
String
,
Object
>
paramMap
)
{
String
param
=
JSON
.
toJSONString
(
paramMap
);
String
param
=
JSON
.
toJSONString
(
paramMap
);
RequestBody
postBody
=
RequestBody
.
create
(
param
,
Constant
.
JSON_TYPE
);
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
();
.
addHeader
(
Constant
.
CONTENT_TYPE_KEY
,
Constant
.
CONTENT_TYPE_VAL
).
build
();
}
}
...
...
src/main/java/com/wuban/tron/explore/service/BlockHeaderService.java
View file @
dee5d47e
package
com
.
wuban
.
tron
.
explore
.
service
;
package
com
.
wuban
.
tron
.
explore
.
service
;
import
com.github.pagehelper.PageInfo
;
import
com.wuban.tron.explore.entity.BlockHeader
;
import
com.wuban.tron.explore.entity.BlockHeader
;
import
com.wuban.tron.explore.entity.example.BlockHeaderExample
;
import
com.wuban.tron.explore.entity.example.BlockHeaderExample
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
/**
* <core>区块头服务接口</core>
* <core>区块头服务接口</core>
*
*
...
@@ -20,4 +23,14 @@ public interface BlockHeaderService {
...
@@ -20,4 +23,14 @@ public interface BlockHeaderService {
*/
*/
BlockHeader
getOneByExample
(
@Param
(
"example"
)
BlockHeaderExample
example
);
BlockHeader
getOneByExample
(
@Param
(
"example"
)
BlockHeaderExample
example
);
/**
* 分页查询
*
* @param startIndex
* @param pageSize
* @param example 查询条件参数
* @return 分页记录列表
*/
PageInfo
<
BlockHeader
>
getByPagerEx
(
Integer
startIndex
,
Integer
pageSize
,
@Param
(
"example"
)
BlockHeaderExample
example
);
}
}
src/main/java/com/wuban/tron/explore/service/TransactionService.java
View file @
dee5d47e
...
@@ -77,7 +77,18 @@ public interface TransactionService {
...
@@ -77,7 +77,18 @@ public interface TransactionService {
* @param pageSize
* @param pageSize
* @return
* @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
);
}
}
src/main/java/com/wuban/tron/explore/service/impl/BlockHeaderServiceImpl.java
View file @
dee5d47e
package
com
.
wuban
.
tron
.
explore
.
service
.
impl
;
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.dao.BlockHeaderRepository
;
import
com.wuban.tron.explore.entity.BlockHeader
;
import
com.wuban.tron.explore.entity.BlockHeader
;
import
com.wuban.tron.explore.entity.example.BlockHeaderExample
;
import
com.wuban.tron.explore.entity.example.BlockHeaderExample
;
...
@@ -8,6 +11,8 @@ import lombok.RequiredArgsConstructor;
...
@@ -8,6 +11,8 @@ import lombok.RequiredArgsConstructor;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
/**
* <core>区块头服务接口实现类</core>
* <core>区块头服务接口实现类</core>
*
*
...
@@ -31,5 +36,33 @@ public class BlockHeaderServiceImpl implements BlockHeaderService {
...
@@ -31,5 +36,33 @@ public class BlockHeaderServiceImpl implements BlockHeaderService {
return
blockHeaderRepository
.
selectOneByExample
(
example
);
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
;
}
}
}
src/main/java/com/wuban/tron/explore/service/impl/TransactionServiceImpl.java
View file @
dee5d47e
...
@@ -8,7 +8,6 @@ import com.wuban.tron.explore.dao.*;
...
@@ -8,7 +8,6 @@ import com.wuban.tron.explore.dao.*;
import
com.wuban.tron.explore.domain.*
;
import
com.wuban.tron.explore.domain.*
;
import
com.wuban.tron.explore.entity.*
;
import
com.wuban.tron.explore.entity.*
;
import
com.wuban.tron.explore.entity.example.TransactionExample
;
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.service.TransactionService
;
import
com.wuban.tron.explore.util.BigDecimalUtil
;
import
com.wuban.tron.explore.util.BigDecimalUtil
;
import
com.wuban.tron.explore.util.DateUtil
;
import
com.wuban.tron.explore.util.DateUtil
;
...
@@ -24,6 +23,8 @@ import org.springframework.stereotype.Service;
...
@@ -24,6 +23,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.tron.common.utils.ByteArray
;
import
org.tron.walletserver.WalletApi
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.math.BigInteger
;
...
@@ -54,8 +55,6 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -54,8 +55,6 @@ public class TransactionServiceImpl implements TransactionService {
private
final
StringRedisTemplate
stringRedisTemplate
;
private
final
StringRedisTemplate
stringRedisTemplate
;
private
Executor
excutor
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
save
(
List
<
TronResponseData
>
dataList
)
{
public
void
save
(
List
<
TronResponseData
>
dataList
)
{
...
@@ -103,17 +102,31 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -103,17 +102,31 @@ public class TransactionServiceImpl implements TransactionService {
区块头、区块交易、hex持久化
区块头、区块交易、hex持久化
*/
*/
this
.
blockHeaderRepository
.
batchInsert
(
headerList
);
this
.
blockHeaderRepository
.
batchInsert
(
headerList
);
Set
<
String
>
set
=
new
HashSet
<>();
Set
<
String
>
hexSet
=
new
HashSet
<>();
Set
<
String
>
base58Set
=
new
HashSet
<>();
if
(
transactionList
.
size
()
!=
0
)
{
if
(
transactionList
.
size
()
!=
0
)
{
transactionList
.
forEach
(
o
->
{
transactionList
.
forEach
(
o
->
{
// hex 数据转换成base58
String
ownerAddress
;
String
toAddress
;
String
contractAddress
;
if
(!
StringUtils
.
isEmpty
(
o
.
getOwnerAddress
()))
{
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
()))
{
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
()))
{
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
);
this
.
transactionRepository
.
batchInsert
(
transactionList
);
...
@@ -127,12 +140,10 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -127,12 +140,10 @@ public class TransactionServiceImpl implements TransactionService {
this
.
lastBlockRepository
.
updateCurBlockNumById
(
lastBlock
);
this
.
lastBlockRepository
.
updateCurBlockNumById
(
lastBlock
);
log
.
info
(
"已同步数据区块高度num:{}"
,
headerList
.
get
(
0
).
getNumber
());
log
.
info
(
"已同步数据区块高度num:{}"
,
headerList
.
get
(
0
).
getNumber
());
List
<
Address
>
records
=
transferAddress
(
s
et
);
List
<
Address
>
records
=
transferAddress
(
base58S
et
);
if
(!
CollectionUtils
.
isEmpty
(
records
))
{
if
(!
CollectionUtils
.
isEmpty
(
records
))
{
this
.
addressRepository
.
batchInsertOnDuplicateKey
(
records
);
this
.
addressRepository
.
batchInsertOnDuplicateKey
(
records
);
/* AccountBalanceTask task = new AccountBalanceTask(set);
addressPushRedis
(
hexSet
);
excutor.execute(task);*/
addressPushRedis
(
set
);
}
}
}
}
...
@@ -204,6 +215,7 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -204,6 +215,7 @@ public class TransactionServiceImpl implements TransactionService {
Contract
contract
=
rawData
.
getContract
().
get
(
0
);
Contract
contract
=
rawData
.
getContract
().
get
(
0
);
ContractParameter
contractParameter
=
contract
.
getParameter
();
ContractParameter
contractParameter
=
contract
.
getParameter
();
ContractParameterValue
val
=
contractParameter
.
getValue
();
ContractParameterValue
val
=
contractParameter
.
getValue
();
Transaction
tr
=
Transaction
.
builder
()
Transaction
tr
=
Transaction
.
builder
()
.
blockId
(
blockId
)
.
blockId
(
blockId
)
.
txId
(
o
.
getTxID
())
.
txId
(
o
.
getTxID
())
...
@@ -229,13 +241,6 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -229,13 +241,6 @@ public class TransactionServiceImpl implements TransactionService {
return
retList
;
return
retList
;
}
}
/*public synchronized void initExcutor() {
if (excutor == null) {
excutor = new Executor(Constant.EXCUTOR_NAME_ACCOUNT, 3);
new AccountBalanceTask();
}
}*/
@Override
@Override
public
Long
getBlockMinTime
()
{
public
Long
getBlockMinTime
()
{
return
this
.
blockHeaderRepository
.
selectBlockMinTime
();
return
this
.
blockHeaderRepository
.
selectBlockMinTime
();
...
@@ -252,6 +257,7 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -252,6 +257,7 @@ public class TransactionServiceImpl implements TransactionService {
@Override
@Override
public
void
censusBlockByDate
(
String
startDate
,
String
endDate
)
{
public
void
censusBlockByDate
(
String
startDate
,
String
endDate
)
{
log
.
info
(
"按天统计交易数据开始startDate:{} 结束endDate:{}"
,
startDate
,
endDate
);
if
(
StringUtils
.
isEmpty
(
endDate
)
||
(
startDate
.
equals
(
endDate
)))
{
if
(
StringUtils
.
isEmpty
(
endDate
)
||
(
startDate
.
equals
(
endDate
)))
{
String
_startDate
=
startDate
+
" 00:00:00"
;
String
_startDate
=
startDate
+
" 00:00:00"
;
String
_endDate
=
startDate
+
" 23:59:59"
;
String
_endDate
=
startDate
+
" 23:59:59"
;
...
@@ -263,14 +269,14 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -263,14 +269,14 @@ public class TransactionServiceImpl implements TransactionService {
while
(
true
)
{
while
(
true
)
{
String
_startDate
=
date
+
" 00:00:00"
;
String
_startDate
=
date
+
" 00:00:00"
;
String
_endDate
=
date
+
" 23:59:59"
;
String
_endDate
=
date
+
" 23:59:59"
;
this
.
census
(
startD
ate
,
_startDate
,
_endDate
);
this
.
census
(
d
ate
,
_startDate
,
_endDate
);
if
(
date
==
endDate
)
{
if
(
date
.
equals
(
endDate
)
)
{
break
;
break
;
}
}
Date
nextDate
=
DateUtil
.
addDays
(
new
Date
()
,
1
);
Date
nextDate
=
DateUtil
.
addDays
(
date
,
1
);
date
=
DateUtil
.
getFormatDate
(
nextDate
,
DateUtil
.
PATTERN_YMD
);
date
=
DateUtil
.
getFormatDate
(
nextDate
,
DateUtil
.
PATTERN_YMD
);
}
}
}
}
...
@@ -316,7 +322,7 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -316,7 +322,7 @@ public class TransactionServiceImpl implements TransactionService {
}
}
@Override
@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
;
Date
date
;
switch
(
type
)
{
switch
(
type
)
{
case
1
:
case
1
:
...
@@ -329,10 +335,10 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -329,10 +335,10 @@ public class TransactionServiceImpl implements TransactionService {
date
=
DateUtil
.
addDays
(
new
Date
(),
-
30
);
date
=
DateUtil
.
addDays
(
new
Date
(),
-
30
);
break
;
break
;
default
:
default
:
date
=
DateUtil
.
addDays
(
new
Date
(),
-
7
)
;
date
=
null
;
}
}
String
str
=
DateUtil
.
getFormatDate
(
date
,
DateUtil
.
PATTERN_YMD_HMS
);
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
)
{
if
(
startIndex
==
null
)
{
startIndex
=
PageConstant
.
DEFAULT_START_INDEX
;
startIndex
=
PageConstant
.
DEFAULT_START_INDEX
;
...
@@ -353,9 +359,38 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -353,9 +359,38 @@ public class TransactionServiceImpl implements TransactionService {
return
pageInfo
;
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
)
{
private
void
census
(
String
date
,
String
startDate
,
String
endDate
)
{
Long
startDateSeconds
=
DateUtil
.
getDateFromDateStr
(
startDate
);
Long
startDateSeconds
=
DateUtil
.
getDateFromDateStr
(
startDate
,
DateUtil
.
PATTERN_YMD_HMS
);
Long
endDateSeconds
=
DateUtil
.
getDateFromDateStr
(
endDate
);
Long
endDateSeconds
=
DateUtil
.
getDateFromDateStr
(
endDate
,
DateUtil
.
PATTERN_YMD_HMS
);
BlockDayCensus
data
=
this
.
blockDayCensusRepository
.
censusBlockByTime
(
startDateSeconds
,
endDateSeconds
);
BlockDayCensus
data
=
this
.
blockDayCensusRepository
.
censusBlockByTime
(
startDateSeconds
,
endDateSeconds
);
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
Long
totalSeconds
=
24
*
60
*
60L
;
Long
totalSeconds
=
24
*
60
*
60L
;
...
@@ -367,6 +402,9 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -367,6 +402,9 @@ public class TransactionServiceImpl implements TransactionService {
BigDecimal
averBlockBytes
=
BigDecimalUtil
.
getDevide
(
new
BigDecimal
(
data
.
getTotalBlockBytes
()),
new
BigDecimal
(
data
.
getGenBlockTotalNum
()));
BigDecimal
averBlockBytes
=
BigDecimalUtil
.
getDevide
(
new
BigDecimal
(
data
.
getTotalBlockBytes
()),
new
BigDecimal
(
data
.
getGenBlockTotalNum
()));
data
.
setAverBlockBytes
(
averBlockBytes
.
intValue
());
data
.
setAverBlockBytes
(
averBlockBytes
.
intValue
());
this
.
blockDayCensusRepository
.
insert
(
data
);
this
.
blockDayCensusRepository
.
insert
(
data
);
log
.
info
(
"date:{} 交易数据已统计完成"
,
date
);
}
else
{
log
.
info
(
"date:{} 暂无交易数据统计"
,
date
);
}
}
}
}
...
...
src/main/java/com/wuban/tron/explore/util/ApiResponse.java
View file @
dee5d47e
...
@@ -21,46 +21,36 @@ public class ApiResponse<T> {
...
@@ -21,46 +21,36 @@ public class ApiResponse<T> {
public
static
final
String
DEFAULT_SUCCESS_MESSAGE
=
"操作成功"
;
public
static
final
String
DEFAULT_SUCCESS_MESSAGE
=
"操作成功"
;
private
Boolean
success
;
private
Integer
error
;
private
Integer
code
;
private
String
err_msg
;
private
String
msg
;
private
T
data
;
private
T
data
;
public
ApiResponse
()
{
public
ApiResponse
()
{
}
}
public
ApiResponse
(
Boolean
success
,
Integer
code
,
String
message
,
T
data
)
{
public
ApiResponse
(
Integer
error
,
String
message
,
T
data
)
{
this
.
success
=
success
;
this
.
error
=
error
;
this
.
code
=
code
;
this
.
err_msg
=
message
;
this
.
msg
=
message
;
this
.
data
=
data
;
this
.
data
=
data
;
}
}
public
Boolean
getSuccess
()
{
public
Integer
getError
()
{
return
success
;
return
error
;
}
}
public
void
set
Success
(
Boolean
success
)
{
public
void
set
Error
(
Integer
error
)
{
this
.
success
=
success
;
this
.
error
=
error
;
}
}
public
Integer
getCode
()
{
public
String
getErr_msg
()
{
return
code
;
return
err_msg
;
}
}
public
void
set
Code
(
Integer
code
)
{
public
void
set
Err_msg
(
String
err_msg
)
{
this
.
code
=
code
;
this
.
err_msg
=
err_msg
;
}
}
public
String
getMsg
()
{
public
T
getData
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
Object
getData
()
{
return
data
;
return
data
;
}
}
...
...
src/main/java/com/wuban/tron/explore/util/DateUtil.java
View file @
dee5d47e
...
@@ -165,6 +165,31 @@ public class DateUtil {
...
@@ -165,6 +165,31 @@ public class DateUtil {
* @return
* @return
*/
*/
public
static
Date
addDays
(
final
Date
date
,
final
int
days
)
{
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
();
final
Calendar
cal
=
Calendar
.
getInstance
();
if
(
date
!=
null
)
{
if
(
date
!=
null
)
{
cal
.
setTime
(
date
);
cal
.
setTime
(
date
);
...
@@ -231,8 +256,8 @@ public class DateUtil {
...
@@ -231,8 +256,8 @@ public class DateUtil {
* @param date
* @param date
* @return
* @return
*/
*/
public
static
Long
getDateFromDateStr
(
String
date
)
{
public
static
Long
getDateFromDateStr
(
String
date
,
String
pattern
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
format
=
new
SimpleDateFormat
(
pattern
);
try
{
try
{
Date
dateTime
=
format
.
parse
(
date
);
Date
dateTime
=
format
.
parse
(
date
);
return
dateTime
.
getTime
();
return
dateTime
.
getTime
();
...
...
src/main/java/com/wuban/tron/explore/util/ErrorResponseData.java
View file @
dee5d47e
...
@@ -12,11 +12,11 @@ package com.wuban.tron.explore.util;
...
@@ -12,11 +12,11 @@ package com.wuban.tron.explore.util;
public
class
ErrorResponseData
extends
ApiResponse
{
public
class
ErrorResponseData
extends
ApiResponse
{
public
ErrorResponseData
(
Integer
code
,
String
message
)
{
public
ErrorResponseData
(
Integer
code
,
String
message
)
{
super
(
false
,
code
,
message
,
null
);
super
(
code
,
message
,
null
);
}
}
public
ErrorResponseData
(
Integer
code
,
String
message
,
Object
object
)
{
public
ErrorResponseData
(
Integer
code
,
String
message
,
Object
object
)
{
super
(
false
,
code
,
message
,
object
);
super
(
code
,
message
,
object
);
}
}
}
}
src/main/java/com/wuban/tron/explore/util/SuccessResponseData.java
View file @
dee5d47e
...
@@ -12,14 +12,14 @@ package com.wuban.tron.explore.util;
...
@@ -12,14 +12,14 @@ package com.wuban.tron.explore.util;
public
class
SuccessResponseData
<
T
>
extends
ApiResponse
{
public
class
SuccessResponseData
<
T
>
extends
ApiResponse
{
public
SuccessResponseData
()
{
public
SuccessResponseData
()
{
super
(
true
,
OK
,
DEFAULT_SUCCESS_MESSAGE
,
null
);
super
(
OK
,
DEFAULT_SUCCESS_MESSAGE
,
null
);
}
}
public
SuccessResponseData
(
T
object
)
{
public
SuccessResponseData
(
T
object
)
{
super
(
true
,
OK
,
DEFAULT_SUCCESS_MESSAGE
,
object
);
super
(
OK
,
DEFAULT_SUCCESS_MESSAGE
,
object
);
}
}
public
SuccessResponseData
(
String
message
,
Object
object
)
{
public
SuccessResponseData
(
String
message
,
Object
object
)
{
super
(
true
,
OK
,
message
,
object
);
super
(
OK
,
message
,
object
);
}
}
}
}
src/main/resources/application-dev.yml
0 → 100644
View file @
dee5d47e
# 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
src/main/resources/application-test.yml
0 → 100644
View file @
dee5d47e
# 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
src/main/resources/application.yml
View file @
dee5d47e
server
:
server
:
port
:
8080
port
:
8080
# config
spring
:
spring
:
datasource
:
profiles
:
type
:
com.alibaba.druid.pool.DruidDataSource
active
:
driverClassName
:
com.mysql.cj.jdbc.Driver
-
dev
url
:
jdbc:mysql://coupon-d.mysql.db.wuban.net.cn:30101/tron-explore?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
application
:
username
:
root
name
:
tron-explore
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
mybatis
:
mybatis
:
mapper-locations
:
classpath:*.xml
mapper-locations
:
classpath:*.xml
type-aliases-package
:
com.wuban.tron.explore.entity
type-aliases-package
:
com.wuban.tron.explore.entity
logging
:
logging
:
level
:
level
:
com.wuban.tron.explore.dao
:
error
com.wuban.tron.explore.dao
:
debug
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/BlockHeaderMapper.xml
View file @
dee5d47e
...
@@ -266,4 +266,16 @@
...
@@ -266,4 +266,16 @@
from
<include
refid=
"Table_Name"
/>
from
<include
refid=
"Table_Name"
/>
</select>
</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>
</mapper>
src/main/resources/mapper/TransactionMapper.xml
View file @
dee5d47e
...
@@ -305,4 +305,12 @@
...
@@ -305,4 +305,12 @@
where (`timestamp`
>
#{t}) and (owner_address = #{address} or to_address = #{address})
where (`timestamp`
>
#{t}) and (owner_address = #{address} or to_address = #{address})
order by `timestamp` desc
order by `timestamp` desc
</select>
</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>
</mapper>
src/test/java/com/wuban/tron/explore/dao/BlockHeaderRepositoryTest.java
View file @
dee5d47e
...
@@ -53,7 +53,7 @@ class BlockHeaderRepositoryTest {
...
@@ -53,7 +53,7 @@ class BlockHeaderRepositoryTest {
void
testDateDely
()
{
void
testDateDely
()
{
Date
nextDate
=
DateUtil
.
addDays
(
new
Date
(),
1
);
Date
nextDate
=
DateUtil
.
addDays
(
new
Date
(),
1
);
String
date
=
DateUtil
.
getFormatDate
(
nextDate
,
"yyyy-MM-dd"
)
+
" 00:00:01"
;
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
+
"--------------------"
);
System
.
out
.
println
(
millis
+
"--------------------"
);
}
}
...
...
src/test/java/com/wuban/tron/explore/dao/TransactionRepositoryTest.java
View file @
dee5d47e
...
@@ -5,8 +5,6 @@ import com.wuban.tron.explore.entity.Transaction;
...
@@ -5,8 +5,6 @@ import com.wuban.tron.explore.entity.Transaction;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.tron.common.utils.ByteArray
;
import
org.tron.walletserver.WalletApi
;
import
java.util.List
;
import
java.util.List
;
...
@@ -32,9 +30,9 @@ class TransactionRepositoryTest extends BaseTest {
...
@@ -32,9 +30,9 @@ class TransactionRepositoryTest extends BaseTest {
@Test
@Test
void
test
()
{
void
test
()
{
String
hexString
=
"416c4858d8d3435d278a34146d49dd7e126879ba0d"
;
/*
String hexString = "416c4858d8d3435d278a34146d49dd7e126879ba0d";
String base58check = WalletApi.encode58Check(ByteArray.fromHexString(hexString));
String base58check = WalletApi.encode58Check(ByteArray.fromHexString(hexString));
System
.
out
.
println
(
base58check
);
System.out.println(base58check);
*/
}
}
}
}
\ No newline at end of file
tron-explore.sql
View file @
dee5d47e
...
@@ -129,7 +129,7 @@ CREATE TABLE `tron_transaction` (
...
@@ -129,7 +129,7 @@ CREATE TABLE `tron_transaction` (
DROP
TABLE
IF
EXISTS
`tron_transaction_hex`
;
DROP
TABLE
IF
EXISTS
`tron_transaction_hex`
;
CREATE
TABLE
`tron_transaction_hex`
(
CREATE
TABLE
`tron_transaction_hex`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`hex`
text
COLLATE
utf8mb4_unicode_ci
,
`hex`
long
text
COLLATE
utf8mb4_unicode_ci
,
`block_id`
varchar
(
80
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
COMMENT
'区块ID'
,
`block_id`
varchar
(
80
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
COMMENT
'区块ID'
,
`tx_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
,
`signature`
varchar
(
150
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment