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
bcec3b74
Commit
bcec3b74
authored
Dec 08, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微调
parent
77158cb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
50 deletions
+29
-50
TransactionServiceImpl.java
...ban/tron/explore/service/impl/TransactionServiceImpl.java
+29
-50
No files found.
src/main/java/com/wuban/tron/explore/service/impl/TransactionServiceImpl.java
View file @
bcec3b74
...
...
@@ -101,16 +101,41 @@ public class TransactionServiceImpl implements TransactionService {
区块头、区块交易、hex持久化
*/
this
.
blockHeaderRepository
.
batchInsert
(
headerList
);
Integer
censusTransNumber
=
0
;
Set
<
String
>
hexSet
=
new
HashSet
<>();
Set
<
String
>
base58Set
=
new
HashSet
<>();
Set
<
String
>
conAddrSet
=
new
HashSet
<>();
if
(
transactionList
.
size
()
!=
0
)
{
censusTransNumber
=
transactionList
.
size
();
transactionList
.
forEach
(
o
->
{
// hex 数据转换成base58
String
ownerAddress
;
String
toAddress
;
String
contractAddress
;
if
(!
StringUtils
.
isEmpty
(
o
.
getOwnerAddress
()))
{
hexSet
.
add
(
o
.
getOwnerAddress
());
ownerAddress
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
o
.
getOwnerAddress
()));
o
.
setOwnerAddress
(
ownerAddress
);
base58Set
.
add
(
ownerAddress
);
}
if
(!
StringUtils
.
isEmpty
(
o
.
getToAddress
()))
{
hexSet
.
add
(
o
.
getToAddress
());
toAddress
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
o
.
getToAddress
()));
o
.
setToAddress
(
toAddress
);
base58Set
.
add
(
toAddress
);
}
if
(!
StringUtils
.
isEmpty
(
o
.
getContractAddress
()))
{
hexSet
.
add
(
o
.
getContractAddress
());
contractAddress
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
o
.
getContractAddress
()));
o
.
setContractAddress
(
contractAddress
);
base58Set
.
add
(
contractAddress
);
conAddrSet
.
add
(
contractAddress
);
}
});
this
.
transactionRepository
.
batchInsert
(
transactionList
);
this
.
transactionHexRepository
.
batchInsert
(
hexList
);
}
Map
<
String
,
Set
<
String
>>
map
=
getAddress
(
transactionList
);
Set
<
String
>
hexSet
=
map
.
get
(
"hexSet"
);
Set
<
String
>
base58Set
=
map
.
get
(
"base58Set"
);
Set
<
String
>
conAddrSet
=
map
.
get
(
"conAddrSet"
);
// 更新区块高度
LastBlock
lastBlock
=
new
LastBlock
();
...
...
@@ -133,52 +158,6 @@ public class TransactionServiceImpl implements TransactionService {
}
/**
* 获取账户、合约地址
* hexSet:hex地址
* base58Set:base58地址
* conAddrSet:合约地址
* @param tranList 交易列表
* @return
*/
private
Map
<
String
,
Set
<
String
>>
getAddress
(
List
<
Transaction
>
tranList
)
{
Map
<
String
,
Set
<
String
>>
map
=
new
HashMap
<>(
3
);
Set
<
String
>
hexSet
=
new
HashSet
<>();
Set
<
String
>
base58Set
=
new
HashSet
<>();
Set
<
String
>
conAddrSet
=
new
HashSet
<>();
tranList
.
forEach
(
o
->
{
// hex 数据转换成base58
String
ownerAddress
;
String
toAddress
;
String
contractAddress
;
if
(!
StringUtils
.
isEmpty
(
o
.
getOwnerAddress
()))
{
hexSet
.
add
(
o
.
getOwnerAddress
());
ownerAddress
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
o
.
getOwnerAddress
()));
o
.
setOwnerAddress
(
ownerAddress
);
base58Set
.
add
(
ownerAddress
);
}
if
(!
StringUtils
.
isEmpty
(
o
.
getToAddress
()))
{
hexSet
.
add
(
o
.
getToAddress
());
toAddress
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
o
.
getToAddress
()));
o
.
setToAddress
(
toAddress
);
base58Set
.
add
(
toAddress
);
}
if
(!
StringUtils
.
isEmpty
(
o
.
getContractAddress
()))
{
hexSet
.
add
(
o
.
getContractAddress
());
contractAddress
=
WalletApi
.
encode58Check
(
ByteArray
.
fromHexString
(
o
.
getContractAddress
()));
o
.
setContractAddress
(
contractAddress
);
base58Set
.
add
(
contractAddress
);
conAddrSet
.
add
(
contractAddress
);
}
});
map
.
put
(
"hexSet"
,
hexSet
);
map
.
put
(
"base58Set"
,
base58Set
);
map
.
put
(
"conAddrSet"
,
conAddrSet
);
return
map
;
}
/**
* 合约地址同步到redis
* @param set
...
...
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