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
Show 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,53 +101,14 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -101,53 +101,14 @@ public class TransactionServiceImpl implements TransactionService {
区块头、区块交易、hex持久化
区块头、区块交易、hex持久化
*/
*/
this
.
blockHeaderRepository
.
batchInsert
(
headerList
);
this
.
blockHeaderRepository
.
batchInsert
(
headerList
);
Integer
censusTransNumber
=
0
;
if
(
transactionList
.
size
()
!=
0
)
{
censusTransNumber
=
transactionList
.
size
();
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
();
lastBlock
.
setId
(
1L
);
lastBlock
.
setCurBlockNum
(
headerList
.
get
(
0
).
getNumber
());
this
.
lastBlockRepository
.
updateCurBlockNumById
(
lastBlock
);
log
.
info
(
"已同步数据区块高度num:{}"
,
headerList
.
get
(
0
).
getNumber
());
// 账户地址push到Redis,未后续抓取账户余额做准备
List
<
Address
>
records
=
transferAddress
(
base58Set
);
if
(!
CollectionUtils
.
isEmpty
(
records
))
{
this
.
addressRepository
.
batchInsertOnDuplicateKey
(
records
);
}
addressPushRedis
(
hexSet
);
conAddrPushRedis
(
conAddrSet
);
// 数据统计
Integer
censusTransNumber
=
0
;
this
.
censusFlushRedis
(
censusBlockSize
,
censusTransNumber
);
}
}
/**
* 获取账户、合约地址
* 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
>
hexSet
=
new
HashSet
<>();
Set
<
String
>
base58Set
=
new
HashSet
<>();
Set
<
String
>
base58Set
=
new
HashSet
<>();
Set
<
String
>
conAddrSet
=
new
HashSet
<>();
Set
<
String
>
conAddrSet
=
new
HashSet
<>();
if
(
transactionList
.
size
()
!=
0
)
{
tranList
.
forEach
(
o
->
{
censusTransNumber
=
transactionList
.
size
();
transactionList
.
forEach
(
o
->
{
// hex 数据转换成base58
// hex 数据转换成base58
String
ownerAddress
;
String
ownerAddress
;
String
toAddress
;
String
toAddress
;
...
@@ -172,11 +133,29 @@ public class TransactionServiceImpl implements TransactionService {
...
@@ -172,11 +133,29 @@ public class TransactionServiceImpl implements TransactionService {
conAddrSet
.
add
(
contractAddress
);
conAddrSet
.
add
(
contractAddress
);
}
}
});
});
this
.
transactionRepository
.
batchInsert
(
transactionList
);
this
.
transactionHexRepository
.
batchInsert
(
hexList
);
}
// 更新区块高度
LastBlock
lastBlock
=
new
LastBlock
();
lastBlock
.
setId
(
1L
);
lastBlock
.
setCurBlockNum
(
headerList
.
get
(
0
).
getNumber
());
this
.
lastBlockRepository
.
updateCurBlockNumById
(
lastBlock
);
log
.
info
(
"已同步数据区块高度num:{}"
,
headerList
.
get
(
0
).
getNumber
());
// 账户地址push到Redis,未后续抓取账户余额做准备
List
<
Address
>
records
=
transferAddress
(
base58Set
);
if
(!
CollectionUtils
.
isEmpty
(
records
))
{
this
.
addressRepository
.
batchInsertOnDuplicateKey
(
records
);
}
addressPushRedis
(
hexSet
);
conAddrPushRedis
(
conAddrSet
);
// 数据统计
this
.
censusFlushRedis
(
censusBlockSize
,
censusTransNumber
);
}
map
.
put
(
"hexSet"
,
hexSet
);
map
.
put
(
"base58Set"
,
base58Set
);
map
.
put
(
"conAddrSet"
,
conAddrSet
);
return
map
;
}
}
/**
/**
...
...
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