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

微调

parent 77158cb6
...@@ -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;
} }
/** /**
......
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