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

微调

parent 77158cb6
......@@ -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
......
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