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
3630a582
Commit
3630a582
authored
Nov 19, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账户余额功能调整
parent
370e0efd
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
125 additions
and
30 deletions
+125
-30
Bootstrapper.java
src/main/java/com/wuban/tron/explore/Bootstrapper.java
+1
-1
TransactionControllerV1.java
...n/tron/explore/controller/v1/TransactionControllerV1.java
+54
-6
TronAccount.java
src/main/java/com/wuban/tron/explore/domain/TronAccount.java
+3
-0
TronFreeze.java
src/main/java/com/wuban/tron/explore/domain/TronFreeze.java
+11
-0
Address.java
src/main/java/com/wuban/tron/explore/entity/Address.java
+12
-12
Engine.java
src/main/java/com/wuban/tron/explore/fetch/Engine.java
+2
-2
Executor.java
src/main/java/com/wuban/tron/explore/fetch/Executor.java
+3
-3
AddressBalanceHandler.java
...com/wuban/tron/explore/handler/AddressBalanceHandler.java
+16
-1
BaseCommonService.java
...ava/com/wuban/tron/explore/service/BaseCommonService.java
+2
-0
BlockHeaderServiceImpl.java
...ban/tron/explore/service/impl/BlockHeaderServiceImpl.java
+1
-1
TronServiceImpl.java
.../com/wuban/tron/explore/service/impl/TronServiceImpl.java
+1
-0
BigDecimalUtil.java
...main/java/com/wuban/tron/explore/util/BigDecimalUtil.java
+1
-0
DateUtil.java
src/main/java/com/wuban/tron/explore/util/DateUtil.java
+1
-1
AddressMapper.xml
src/main/resources/mapper/AddressMapper.xml
+4
-2
TronServiceImplTest.java
.../wuban/tron/explore/service/impl/TronServiceImplTest.java
+13
-1
No files found.
src/main/java/com/wuban/tron/explore/Bootstrapper.java
View file @
3630a582
...
@@ -62,7 +62,7 @@ public class Bootstrapper {
...
@@ -62,7 +62,7 @@ public class Bootstrapper {
public
synchronized
void
start
()
{
public
synchronized
void
start
()
{
this
.
init
();
this
.
init
();
this
.
startEngine
();
this
.
startEngine
();
this
.
executorService
.
scheduleWithFixedDelay
(()
->
this
.
lastBlockService
.
sync
(),
0
,
3
0
,
TimeUnit
.
MINUTES
);
this
.
executorService
.
scheduleWithFixedDelay
(()
->
this
.
lastBlockService
.
sync
(),
0
,
3
,
TimeUnit
.
MINUTES
);
this
.
executorService
.
scheduleWithFixedDelay
(()
->
this
.
lastBlockService
.
refresh
(),
1
,
1
,
TimeUnit
.
MINUTES
);
this
.
executorService
.
scheduleWithFixedDelay
(()
->
this
.
lastBlockService
.
refresh
(),
1
,
1
,
TimeUnit
.
MINUTES
);
this
.
executorService
.
scheduleWithFixedDelay
(()
->
this
.
transactionService
.
censusBlockByLastDay
(),
getInitialDelay
(),
24
*
60
*
60
,
TimeUnit
.
SECONDS
);
this
.
executorService
.
scheduleWithFixedDelay
(()
->
this
.
transactionService
.
censusBlockByLastDay
(),
getInitialDelay
(),
24
*
60
*
60
,
TimeUnit
.
SECONDS
);
}
}
...
...
src/main/java/com/wuban/tron/explore/controller/v1/TransactionControllerV1.java
View file @
3630a582
...
@@ -99,7 +99,15 @@ public class TransactionControllerV1 {
...
@@ -99,7 +99,15 @@ public class TransactionControllerV1 {
Address
address
=
this
.
addressService
.
selectOneByExample
(
addressExample
);
Address
address
=
this
.
addressService
.
selectOneByExample
(
addressExample
);
if
(
address
!=
null
)
{
if
(
address
!=
null
)
{
model
.
setAddress
(
address
.
getAddress
());
model
.
setAddress
(
address
.
getAddress
());
model
.
setBalance
(
address
.
getBalance
()+
""
);
// 账户余额 = 可用余额+冻结余额
BigDecimal
accountBalance
=
new
BigDecimal
(
0
);
if
(
address
.
getBalance
()
!=
null
)
{
accountBalance
=
BigDecimalUtil
.
getAdd
(
accountBalance
,
new
BigDecimal
(
address
.
getBalance
()));
}
if
(
address
.
getFrozenBalance
()
!=
null
)
{
accountBalance
=
BigDecimalUtil
.
getAdd
(
accountBalance
,
new
BigDecimal
(
address
.
getFrozenBalance
()));
}
model
.
setBalance
(
accountBalance
.
toPlainString
());
}
}
resDataModel
.
setData
(
model
);
resDataModel
.
setData
(
model
);
resDataModel
.
setT
(
HomeSearchTypeEnum
.
ADDRESS_INFO
.
getCode
());
resDataModel
.
setT
(
HomeSearchTypeEnum
.
ADDRESS_INFO
.
getCode
());
...
@@ -148,8 +156,8 @@ public class TransactionControllerV1 {
...
@@ -148,8 +156,8 @@ public class TransactionControllerV1 {
@RequestMapping
(
value
=
"indexGetBlockInfo"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"indexGetBlockInfo"
,
method
=
RequestMethod
.
GET
)
public
ApiResponse
lastBlockList
()
{
public
ApiResponse
lastBlockList
()
{
BlockHeaderExample
headerExample
=
new
BlockHeaderExample
();
BlockHeaderExample
headerExample
=
new
BlockHeaderExample
();
PageInfo
<
BlockHeader
>
pageInfo
=
this
.
blockHeaderService
.
getByPagerEx
(
null
,
null
,
headerExample
);
PageInfo
<
BlockHeader
>
pageInfo
=
this
.
blockHeaderService
.
getByPagerEx
(
1
,
11
,
headerExample
);
List
<
BlockInfoModel
>
list
=
transferBlockInfoModel
(
pageInfo
);
List
<
BlockInfoModel
>
list
=
transferBlockInfoModel
V2
(
pageInfo
);
return
ResponseKit
.
success
(
list
);
return
ResponseKit
.
success
(
list
);
}
}
...
@@ -171,6 +179,33 @@ public class TransactionControllerV1 {
...
@@ -171,6 +179,33 @@ public class TransactionControllerV1 {
return
ResponseKit
.
success
(
model
);
return
ResponseKit
.
success
(
model
);
}
}
private
List
<
BlockInfoModel
>
transferBlockInfoModelV2
(
PageInfo
<
BlockHeader
>
pageInfo
)
{
List
<
BlockInfoModel
>
list
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
pageInfo
.
getList
()))
{
for
(
int
i
=
0
;
i
<
pageInfo
.
getList
().
size
()
-
1
;
i
++)
{
BlockHeader
o
=
pageInfo
.
getList
().
get
(
i
);
BlockInfoModel
model
=
BlockInfoModel
.
getInstance
();
model
.
setNumber
(
o
.
getNumber
());
BlockHeader
pre
=
pageInfo
.
getList
().
get
(
i
+
1
);
Long
preTime
=
pre
.
getTimestamp
()/
1000
;
model
.
setMined_time
(
preTime
.
toString
());
if
(
o
.
getTimestamp
()
!=
null
)
{
Long
tt
=
o
.
getTimestamp
()/
1000
;
model
.
setTimestamp
(
tt
.
toString
());
}
model
.
setMiner
(
o
.
getWitnessAddress
());
model
.
setParentHash
(
o
.
getParentHash
());
model
.
setHash
(
o
.
getBlockId
());
model
.
setTrans_number
(
o
.
getTransactionVolume
());
model
.
setSize
(
o
.
getBlockBytes
());
list
.
add
(
model
);
}
}
return
list
;
}
private
List
<
BlockInfoModel
>
transferBlockInfoModel
(
PageInfo
<
BlockHeader
>
pageInfo
)
{
private
List
<
BlockInfoModel
>
transferBlockInfoModel
(
PageInfo
<
BlockHeader
>
pageInfo
)
{
List
<
BlockInfoModel
>
list
=
new
ArrayList
<>();
List
<
BlockInfoModel
>
list
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
pageInfo
.
getList
()))
{
if
(!
CollectionUtils
.
isEmpty
(
pageInfo
.
getList
()))
{
...
@@ -382,15 +417,27 @@ public class TransactionControllerV1 {
...
@@ -382,15 +417,27 @@ public class TransactionControllerV1 {
PageInfo
<
Address
>
pageInfo
=
this
.
addressService
.
selectByPager
(
pageNo
,
pageSize
,
example
);
PageInfo
<
Address
>
pageInfo
=
this
.
addressService
.
selectByPager
(
pageNo
,
pageSize
,
example
);
resDataModel
.
setTotal
(
Integer
.
parseInt
(
pageInfo
.
getTotal
()+
""
));
resDataModel
.
setTotal
(
Integer
.
parseInt
(
pageInfo
.
getTotal
()+
""
));
List
<
AccountInfoModel
>
modelList
=
new
ArrayList
<>();
List
<
AccountInfoModel
>
modelList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
pageInfo
.
getList
()))
{
if
(!
CollectionUtils
.
isEmpty
(
pageInfo
.
getList
()))
{
pageInfo
.
getList
().
forEach
(
o
->
{
pageInfo
.
getList
().
forEach
(
o
->
{
AccountInfoModel
infoModel
=
AccountInfoModel
.
getInstance
();
AccountInfoModel
infoModel
=
AccountInfoModel
.
getInstance
();
infoModel
.
setAddress
(
o
.
getAddress
());
infoModel
.
setAddress
(
o
.
getAddress
());
infoModel
.
setBalance
(
o
.
getBalance
().
toString
());
//BigDecimal balance = BigDecimalUtil.getDevide(new BigDecimal(o.getBalance()), BigDecimalUtil.NUM);
// 账户余额 = 可用余额+冻结余额
BigDecimal
accountBalance
=
new
BigDecimal
(
0
);
if
(
o
.
getBalance
()
!=
null
)
{
accountBalance
=
BigDecimalUtil
.
getAdd
(
accountBalance
,
new
BigDecimal
(
o
.
getBalance
()));
}
if
(
o
.
getFrozenBalance
()
!=
null
)
{
accountBalance
=
BigDecimalUtil
.
getAdd
(
accountBalance
,
new
BigDecimal
(
o
.
getFrozenBalance
()));
}
infoModel
.
setBalance
(
accountBalance
.
toPlainString
());
modelList
.
add
(
infoModel
);
modelList
.
add
(
infoModel
);
});
});
}
}
BigDecimal
bg
=
this
.
totalBalance
();
BigDecimal
bg
=
this
.
totalBalance
();
resDataModel
.
setSum
(
bg
.
toPlainString
());
resDataModel
.
setSum
(
bg
.
toPlainString
());
resDataModel
.
setData
(
modelList
);
resDataModel
.
setData
(
modelList
);
...
@@ -411,6 +458,7 @@ public class TransactionControllerV1 {
...
@@ -411,6 +458,7 @@ public class TransactionControllerV1 {
}
}
return
totalBalance
;
return
totalBalance
;
//return BigDecimalUtil.getDevide(totalBalance, BigDecimalUtil.NUM);
}
}
/**
/**
...
@@ -427,11 +475,11 @@ public class TransactionControllerV1 {
...
@@ -427,11 +475,11 @@ public class TransactionControllerV1 {
List
<
BlockDayCensus
>
list
=
pageInfo
.
getList
();
List
<
BlockDayCensus
>
list
=
pageInfo
.
getList
();
HomeChartModel
model
;
HomeChartModel
model
;
int
id
=
1
;
int
id
=
1
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
{
for
(
int
i
=
list
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
model
=
new
HomeChartModel
();
model
=
new
HomeChartModel
();
model
.
setId
(
id
);
model
.
setId
(
id
);
long
time
=
DateUtil
.
getDateFromDateStr
(
list
.
get
(
i
).
getCensusDate
(),
DateUtil
.
PATTERN_YMD
);
long
time
=
DateUtil
.
getDateFromDateStr
(
list
.
get
(
i
).
getCensusDate
(),
DateUtil
.
PATTERN_YMD
);
model
.
setTime
(
time
);
model
.
setTime
(
time
/
1000
);
model
.
setCount
(
list
.
get
(
i
).
getTotalVolume
());
model
.
setCount
(
list
.
get
(
i
).
getTotalVolume
());
modelList
.
add
(
model
);
modelList
.
add
(
model
);
id
++;
id
++;
...
...
src/main/java/com/wuban/tron/explore/domain/TronAccount.java
View file @
3630a582
...
@@ -2,6 +2,8 @@ package com.wuban.tron.explore.domain;
...
@@ -2,6 +2,8 @@ package com.wuban.tron.explore.domain;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
/**
/**
* <core>波场区块账号信息</core>
* <core>波场区块账号信息</core>
*
*
...
@@ -13,6 +15,7 @@ public class TronAccount {
...
@@ -13,6 +15,7 @@ public class TronAccount {
private
String
address
;
private
String
address
;
private
Long
balance
;
private
Long
balance
;
private
List
<
TronFreeze
>
frozen
;
/* private Long create_time;
/* private Long create_time;
private Long latest_opration_time;
private Long latest_opration_time;
private Long latest_consume_free_time;
private Long latest_consume_free_time;
...
...
src/main/java/com/wuban/tron/explore/domain/TronFreeze.java
0 → 100644
View file @
3630a582
package
com
.
wuban
.
tron
.
explore
.
domain
;
import
lombok.Data
;
@Data
public
class
TronFreeze
{
private
long
frozen_balance
;
private
long
expire_time
;
}
src/main/java/com/wuban/tron/explore/entity/Address.java
View file @
3630a582
package
com
.
wuban
.
tron
.
explore
.
entity
;
package
com
.
wuban
.
tron
.
explore
.
entity
;
import
lombok.AccessLevel
;
import
lombok.*
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
/**
* 账户地址表
* 账户地址表
...
@@ -19,19 +12,26 @@ import java.util.Date;
...
@@ -19,19 +12,26 @@ import java.util.Date;
@NoArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
(
access
=
AccessLevel
.
PRIVATE
)
@AllArgsConstructor
(
access
=
AccessLevel
.
PRIVATE
)
public
class
Address
{
public
class
Address
{
/**
/**
* 账户地址
* 账户地址
*/
*/
private
String
address
;
private
String
address
;
/**
/**
* 余额
* 余额
*/
*/
private
Long
balance
;
private
Long
balance
;
/**
* 冻结余额
*/
private
Long
frozenBalance
;
public
static
Address
getInstance
()
{
public
static
Address
getInstance
()
{
return
Address
.
builder
()
return
Address
.
builder
()
.
address
(
""
)
.
address
(
""
)
.
balance
(
0L
)
.
balance
(
0L
)
.
frozenBalance
(
0L
)
.
build
();
.
build
();
}
}
}
}
\ No newline at end of file
src/main/java/com/wuban/tron/explore/fetch/Engine.java
View file @
3630a582
...
@@ -45,7 +45,7 @@ public class Engine {
...
@@ -45,7 +45,7 @@ public class Engine {
*/
*/
private
AddressBalanceHandler
addressHandler
;
private
AddressBalanceHandler
addressHandler
;
public
static
final
int
BLOCK_FETCHER_NUM
=
10
;
public
static
final
int
BLOCK_FETCHER_NUM
=
5
;
public
static
final
int
BALANCE_FETCHER_NUM
=
3
;
public
static
final
int
BALANCE_FETCHER_NUM
=
3
;
...
@@ -78,7 +78,7 @@ public class Engine {
...
@@ -78,7 +78,7 @@ public class Engine {
this
.
handler
=
new
BlockDataHandler
();
this
.
handler
=
new
BlockDataHandler
();
this
.
fetcher
=
new
BlockDataFetcher
(
this
.
handler
);
this
.
fetcher
=
new
BlockDataFetcher
(
this
.
handler
);
this
.
executor
.
execute
(
this
.
handler
);
this
.
executor
.
execute
(
this
.
handler
);
for
(
int
i
=
0
;
i
<
=
BLOCK_FETCHER_NUM
;
i
++)
{
for
(
int
i
=
0
;
i
<
BLOCK_FETCHER_NUM
;
i
++)
{
this
.
executor
.
execute
(
this
.
fetcher
);
this
.
executor
.
execute
(
this
.
fetcher
);
}
}
...
...
src/main/java/com/wuban/tron/explore/fetch/Executor.java
View file @
3630a582
...
@@ -20,16 +20,16 @@ import java.util.concurrent.atomic.AtomicInteger;
...
@@ -20,16 +20,16 @@ import java.util.concurrent.atomic.AtomicInteger;
@Slf4j
@Slf4j
public
class
Executor
{
public
class
Executor
{
private
static
final
int
SIZE
=
20
;
private
static
final
int
SIZE
=
15
;
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
;
public
Executor
(
final
String
name
)
{
public
Executor
(
final
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
pool
=
new
ThreadPoolExecutor
(
SIZE
,
SIZE
*
3
,
10L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
this
.
pool
=
new
ThreadPoolExecutor
(
SIZE
,
SIZE
*
2
,
10L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ExecutorThreadFactory
());
new
ExecutorThreadFactory
());
log
.
info
(
"初始化线程池 name:{} coreSize:{} maxSize:{}"
,
name
,
SIZE
,
SIZE
*
3
);
log
.
info
(
"初始化线程池 name:{} coreSize:{} maxSize:{}"
,
name
,
SIZE
,
SIZE
*
2
);
}
}
public
void
execute
(
final
AbstractJob
r
)
{
public
void
execute
(
final
AbstractJob
r
)
{
...
...
src/main/java/com/wuban/tron/explore/handler/AddressBalanceHandler.java
View file @
3630a582
package
com
.
wuban
.
tron
.
explore
.
handler
;
package
com
.
wuban
.
tron
.
explore
.
handler
;
import
com.wuban.tron.explore.domain.TronAccount
;
import
com.wuban.tron.explore.domain.TronAccount
;
import
com.wuban.tron.explore.domain.TronFreeze
;
import
com.wuban.tron.explore.entity.Address
;
import
com.wuban.tron.explore.entity.Address
;
import
com.wuban.tron.explore.fetch.AbstractJob
;
import
com.wuban.tron.explore.fetch.AbstractJob
;
import
com.wuban.tron.explore.fetch.PersistThreadPool
;
import
com.wuban.tron.explore.fetch.PersistThreadPool
;
import
com.wuban.tron.explore.service.AddressService
;
import
com.wuban.tron.explore.service.AddressService
;
import
com.wuban.tron.explore.util.BigDecimalUtil
;
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.common.utils.ByteArray
;
import
org.tron.walletserver.WalletApi
;
import
org.tron.walletserver.WalletApi
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
@@ -54,11 +57,23 @@ public class AddressBalanceHandler extends AbstractJob implements IAddressBalanc
...
@@ -54,11 +57,23 @@ public class AddressBalanceHandler extends AbstractJob implements IAddressBalanc
@Override
@Override
public
void
flush
(
List
<
TronAccount
>
e
)
{
public
void
flush
(
List
<
TronAccount
>
e
)
{
if
(!
CollectionUtils
.
isEmpty
(
e
))
{
if
(!
CollectionUtils
.
isEmpty
(
e
))
{
TronAccount
account
=
e
.
get
(
0
);
Address
obj
=
new
Address
();
Address
obj
=
new
Address
();
String
address
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
e
.
get
(
0
).
getAddress
()));
String
address
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
e
.
get
(
0
).
getAddress
()));
obj
.
setAddress
(
address
);
obj
.
setAddress
(
address
);
obj
.
setBalance
(
e
.
get
(
0
).
getBalance
());
obj
.
setBalance
(
account
.
getBalance
());
// 冻结余额
BigDecimal
frozenBalance
=
new
BigDecimal
(
0
);
List
<
TronFreeze
>
tronFreezes
=
account
.
getFrozen
();
if
(!
CollectionUtils
.
isEmpty
(
tronFreezes
))
{
for
(
int
i
=
0
;
i
<
tronFreezes
.
size
();
i
++)
{
frozenBalance
=
BigDecimalUtil
.
getAdd
(
frozenBalance
,
new
BigDecimal
(
tronFreezes
.
get
(
i
).
getFrozen_balance
()));
}
}
obj
.
setFrozenBalance
(
frozenBalance
.
longValue
());
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/service/BaseCommonService.java
View file @
3630a582
...
@@ -37,6 +37,8 @@ public abstract class BaseCommonService {
...
@@ -37,6 +37,8 @@ public abstract class BaseCommonService {
*/
*/
protected
static
final
String
GET_ACCOUNT
=
PREFIX
+
"/getaccount"
;
protected
static
final
String
GET_ACCOUNT
=
PREFIX
+
"/getaccount"
;
protected
static
final
String
FREEZE_BALANCE
=
"/wallet/freezebalance"
;
@Value
(
"${tron.site}"
)
@Value
(
"${tron.site}"
)
private
String
tronSite
;
private
String
tronSite
;
...
...
src/main/java/com/wuban/tron/explore/service/impl/BlockHeaderServiceImpl.java
View file @
3630a582
...
@@ -56,7 +56,7 @@ public class BlockHeaderServiceImpl implements BlockHeaderService {
...
@@ -56,7 +56,7 @@ public class BlockHeaderServiceImpl implements BlockHeaderService {
pageSize
=
PageConstant
.
MAX_PAGE_SIZE
;
pageSize
=
PageConstant
.
MAX_PAGE_SIZE
;
}
}
example
.
setOrderByClause
(
"`
timestamp
` DESC"
);
example
.
setOrderByClause
(
"`
number
` DESC"
);
PageHelper
.
startPage
(
startIndex
,
pageSize
);
PageHelper
.
startPage
(
startIndex
,
pageSize
);
List
<
BlockHeader
>
list
=
this
.
blockHeaderRepository
.
selectByPagerEx
(
example
);
List
<
BlockHeader
>
list
=
this
.
blockHeaderRepository
.
selectByPagerEx
(
example
);
PageInfo
<
BlockHeader
>
pageInfo
=
new
PageInfo
<>(
list
);
PageInfo
<
BlockHeader
>
pageInfo
=
new
PageInfo
<>(
list
);
...
...
src/main/java/com/wuban/tron/explore/service/impl/TronServiceImpl.java
View file @
3630a582
...
@@ -70,4 +70,5 @@ public class TronServiceImpl extends BaseCommonService implements TronService {
...
@@ -70,4 +70,5 @@ public class TronServiceImpl extends BaseCommonService implements TronService {
return
JSONObject
.
parseObject
(
str
,
TronAccount
.
class
);
return
JSONObject
.
parseObject
(
str
,
TronAccount
.
class
);
}
}
}
}
src/main/java/com/wuban/tron/explore/util/BigDecimalUtil.java
View file @
3630a582
...
@@ -13,6 +13,7 @@ import java.math.RoundingMode;
...
@@ -13,6 +13,7 @@ import java.math.RoundingMode;
public
class
BigDecimalUtil
{
public
class
BigDecimalUtil
{
public
static
final
int
SCALE
=
32
;
public
static
final
int
SCALE
=
32
;
public
static
final
BigDecimal
NUM
=
new
BigDecimal
(
1000000
);
public
static
BigDecimal
getDevide
(
BigDecimal
bg1
,
BigDecimal
bg2
){
public
static
BigDecimal
getDevide
(
BigDecimal
bg1
,
BigDecimal
bg2
){
MathContext
mc
=
new
MathContext
(
SCALE
,
RoundingMode
.
HALF_DOWN
);
MathContext
mc
=
new
MathContext
(
SCALE
,
RoundingMode
.
HALF_DOWN
);
...
...
src/main/java/com/wuban/tron/explore/util/DateUtil.java
View file @
3630a582
...
@@ -169,7 +169,7 @@ public class DateUtil {
...
@@ -169,7 +169,7 @@ public class DateUtil {
if
(
date
!=
null
)
{
if
(
date
!=
null
)
{
cal
.
setTime
(
date
);
cal
.
setTime
(
date
);
}
}
cal
.
add
(
0
,
days
);
cal
.
add
(
Calendar
.
DATE
,
days
);
return
cal
.
getTime
();
return
cal
.
getTime
();
}
}
...
...
src/main/resources/mapper/AddressMapper.xml
View file @
3630a582
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<resultMap
id=
"AddressMap"
type=
"com.wuban.tron.explore.entity.Address"
>
<resultMap
id=
"AddressMap"
type=
"com.wuban.tron.explore.entity.Address"
>
<result
column=
"address"
property=
"address"
jdbcType=
"VARCHAR"
/>
<result
column=
"address"
property=
"address"
jdbcType=
"VARCHAR"
/>
<result
column=
"balance"
property=
"balance"
jdbcType=
"BIGINT"
/>
<result
column=
"balance"
property=
"balance"
jdbcType=
"BIGINT"
/>
<result
column=
"frozen_balance"
property=
"frozenBalance"
jdbcType=
"BIGINT"
/>
</resultMap>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<sql
id=
"Example_Where_Clause"
>
<where>
<where>
...
@@ -59,6 +60,7 @@
...
@@ -59,6 +60,7 @@
<sql
id=
"Update_Set_From_Bean"
>
<sql
id=
"Update_Set_From_Bean"
>
<if
test=
"record.address != null"
>
address = #{record.address,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.address != null"
>
address = #{record.address,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.balance != null"
>
balance = #{record.balance,jdbcType=BIGINT} ,
</if>
<if
test=
"record.balance != null"
>
balance = #{record.balance,jdbcType=BIGINT} ,
</if>
<if
test=
"record.frozenBalance != null"
>
frozen_balance = #{record.frozenBalance,jdbcType=BIGINT} ,
</if>
</sql>
</sql>
<!-- insert -->
<!-- insert -->
<insert
id=
"insert"
parameterType=
"java.util.Map"
>
<insert
id=
"insert"
parameterType=
"java.util.Map"
>
...
@@ -164,7 +166,7 @@
...
@@ -164,7 +166,7 @@
</select>
</select>
<select
id=
"selectOneByExample"
resultMap=
"AddressMap"
parameterType=
"java.util.Map"
>
<select
id=
"selectOneByExample"
resultMap=
"AddressMap"
parameterType=
"java.util.Map"
>
select
select
address,balance
address,balance
,frozen_balance
from
<include
refid=
"Table_Name"
/>
from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
<include
refid=
"Example_Where_Clause"
/>
...
@@ -197,7 +199,7 @@
...
@@ -197,7 +199,7 @@
<select
id=
"selectByPager"
resultMap=
"AddressMap"
parameterType=
"java.util.Map"
>
<select
id=
"selectByPager"
resultMap=
"AddressMap"
parameterType=
"java.util.Map"
>
select
select
address,balance
address,balance
,frozen_balance
from
<include
refid=
"Table_Name"
/>
from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
<include
refid=
"Example_Where_Clause"
/>
...
...
src/test/java/com/wuban/tron/explore/service/impl/TronServiceImplTest.java
View file @
3630a582
package
com
.
wuban
.
tron
.
explore
.
service
.
impl
;
package
com
.
wuban
.
tron
.
explore
.
service
.
impl
;
import
com.wuban.tron.explore.domain.TronAccount
;
import
com.wuban.tron.explore.domain.TronResponseArrayData
;
import
com.wuban.tron.explore.domain.TronResponseArrayData
;
import
com.wuban.tron.explore.domain.TronResponseData
;
import
com.wuban.tron.explore.domain.TronResponseData
;
import
com.wuban.tron.explore.service.TronService
;
import
com.wuban.tron.explore.service.TronService
;
...
@@ -9,6 +10,8 @@ import org.junit.runner.RunWith;
...
@@ -9,6 +10,8 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.tron.common.utils.ByteArray
;
import
org.tron.walletserver.WalletApi
;
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@SpringBootTest
...
@@ -32,7 +35,16 @@ class TronServiceImplTest {
...
@@ -32,7 +35,16 @@ class TronServiceImplTest {
@Test
@Test
void
getAccount
()
{
void
getAccount
()
{
this
.
tronService
.
getAccount
(
"41705b35c6bb37387cd4cfb57bfc83b74d4374a78a"
);
TronAccount
account
=
this
.
tronService
.
getAccount
(
"4151ac26e9d4b3810ce891d660e13202f7cda09a41"
);
System
.
out
.
println
(
account
.
toString
());
}
}
@Test
void
getFreezeBalance
()
{
String
base58check
=
"THR3xvo49HY6UzFQugRTaeUdgWx7zbkM1k"
;
String
hexString
=
ByteArray
.
toHexString
(
WalletApi
.
decodeFromBase58Check
(
base58check
));
log
.
info
(
hexString
);
}
}
}
\ No newline at end of file
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