diff --git a/back-end-projects/Explorer/src/main/resources/db/migration/V1.81__tbl_tx_detail_index_block_index.sql b/back-end-projects/Explorer/src/main/resources/db/migration/V1.81__tbl_tx_detail_index_block_index.sql
new file mode 100644
index 00000000..d0520892
--- /dev/null
+++ b/back-end-projects/Explorer/src/main/resources/db/migration/V1.81__tbl_tx_detail_index_block_index.sql
@@ -0,0 +1,3 @@
+alter table `tbl_address_daily_summary` add index contract_address_index(`contract_hash`, `address`);
+
+ALTER TABLE tbl_tx_detail_index ADD COLUMN `block_index` int(11) NOT NULL COMMENT '交易在区块里的索引' AFTER `tx_hash`;
\ No newline at end of file
diff --git a/back-end-projects/Explorer/src/main/resources/mapper/TxDetailMapper.xml b/back-end-projects/Explorer/src/main/resources/mapper/TxDetailMapper.xml
index edf5e9c9..60740ae8 100644
--- a/back-end-projects/Explorer/src/main/resources/mapper/TxDetailMapper.xml
+++ b/back-end-projects/Explorer/src/main/resources/mapper/TxDetailMapper.xml
@@ -156,7 +156,7 @@
AND asset_name = #{assetName}
- ORDER BY desc_block_height, tx_hash, tx_index
+ ORDER BY desc_block_height, block_index
LIMIT #{startIndex}, #{pageSize}
) idx ON idx.hash = d.tx_hash
LEFT JOIN tbl_contract c ON d.contract_hash = c.contract_hash
@@ -166,7 +166,7 @@
AND d.asset_name = #{assetName}
AND d.event_type IN (2, 3)
- ORDER BY block_height DESC, block_index, tx_hash, tx_index
+ ORDER BY block_height DESC, block_index, tx_index
@@ -183,9 +183,9 @@
AND asset_name = #{assetName}
- ORDER BY desc_block_height, tx_hash, tx_index
+ ORDER BY desc_block_height, block_index
) idx ON idx.hash = d.tx_hash AND idx.`index` = d.tx_index
- ORDER BY block_height DESC, block_index
+ ORDER BY block_height DESC, block_index, tx_index
@@ -451,13 +451,13 @@
ON o.contract_hash = idx.called_contract_hash
WHERE idx.address = #{address}
AND o.audit_flag = 1
- ORDER BY idx.desc_block_height, idx.tx_hash, idx.tx_index
+ ORDER BY idx.desc_block_height, idx.block_index
LIMIT #{startIndex}, #{pageSize}
) idx ON idx.hash = d.tx_hash
WHERE d.from_address = #{address}
OR d.to_address = #{address}
AND d.event_type IN (2, 3)
- ORDER BY block_height DESC, block_index, tx_hash, tx_index
+ ORDER BY block_height DESC, block_index, tx_index
@@ -599,12 +599,12 @@
)
- ORDER BY idx.desc_block_height, idx.tx_hash, idx.tx_index
+ ORDER BY idx.desc_block_height, idx.block_index
LIMIT #{startIndex}, #{pageSize}
) idx ON idx.hash = d.tx_hash
WHERE (d.from_address = #{address}
OR d.to_address = #{address})
- ORDER BY block_height DESC, block_index, tx_hash, tx_index
+ ORDER BY block_height DESC, block_index, tx_index
diff --git a/back-end-projects/OntSynHandler/src/main/java/com/github/ontio/thread/TxHandlerThread.java b/back-end-projects/OntSynHandler/src/main/java/com/github/ontio/thread/TxHandlerThread.java
index 77f3fed7..bd3deefb 100644
--- a/back-end-projects/OntSynHandler/src/main/java/com/github/ontio/thread/TxHandlerThread.java
+++ b/back-end-projects/OntSynHandler/src/main/java/com/github/ontio/thread/TxHandlerThread.java
@@ -1551,7 +1551,7 @@ private void handleUnauditedOrcTransferTx(String evmStates, int txType, String t
String contractHash = (String) result.get("contractHash");
String assetName = (String) result.get("assetName");
if (assetName == null) {
- throw new RuntimeException("cannot get assetName,not orc20");
+ assetName = "ORC-20 TOKEN";
}
TxDetail txDetail = generateTransaction(fromAddress, toAddress, assetName, amount, txType, txHash, blockHeight, blockTime, indexInBlock, confirmFlag, txAction, gasConsumed, indexInTx, eventType, contractHash, payer, calledContractHash);
ConstantParam.BATCHBLOCKDTO.getTxDetails().add(txDetail);
@@ -1566,7 +1566,7 @@ private void handleUnauditedOrcTransferTx(String evmStates, int txType, String t
String contractHash = (String) result.get("contractHash");
String assetName = (String) result.get("assetName");
if (assetName == null) {
- throw new RuntimeException("cannot get assetName,not orc721");
+ assetName = "ORC-721 NFT";
}
TxDetail txDetail = generateTransaction(fromAddress, toAddress, assetName, BigDecimal.ONE, txType, txHash, blockHeight, blockTime, indexInBlock, confirmFlag, txAction, gasConsumed, indexInTx, eventType, contractHash, payer, calledContractHash);
ConstantParam.BATCHBLOCKDTO.getTxDetails().add(txDetail);
@@ -1584,7 +1584,7 @@ private void handleUnauditedOrcTransferTx(String evmStates, int txType, String t
String contractHash = (String) result.get("contractHash");
String assetName = (String) result.get("assetName");
if (assetName == null) {
- throw new RuntimeException("cannot get assetName,not orc1155");
+ assetName = "ORC-1155 NFT";
}
if (tokenIds instanceof String) {
String tokenId = (String) tokenIds;
@@ -1609,15 +1609,17 @@ private void handleUnauditedOrcTransferTx(String evmStates, int txType, String t
}
} else {
// other
+ String contractHash = ConstantParam.EVM_ADDRESS_PREFIX + Helper.reverse(contractAddress);
TxDetail txDetail = generateTransaction(ConstantParam.EMPTY, ConstantParam.EMPTY, ConstantParam.EMPTY, ConstantParam.ZERO, txType, txHash, blockHeight,
- blockTime, indexInBlock, confirmFlag, ConstantParam.EMPTY, gasConsumed, indexInTx, EventTypeEnum.Others.type(), contractAddress, payer, calledContractHash);
+ blockTime, indexInBlock, confirmFlag, ConstantParam.EMPTY, gasConsumed, indexInTx, EventTypeEnum.Others.type(), contractHash, payer, calledContractHash);
ConstantParam.BATCHBLOCKDTO.getTxDetails().add(txDetail);
ConstantParam.BATCHBLOCKDTO.getTxDetailDailys().add(TxDetail.toTxDetailDaily(txDetail));
}
} catch (Exception e) {
log.error("handleUnAuditedOrcTransferTx error", e);
+ String contractHash = ConstantParam.EVM_ADDRESS_PREFIX + Helper.reverse(contractAddress);
TxDetail txDetail = generateTransaction(ConstantParam.EMPTY, ConstantParam.EMPTY, ConstantParam.EMPTY, ConstantParam.ZERO, txType, txHash, blockHeight,
- blockTime, indexInBlock, confirmFlag, ConstantParam.EMPTY, gasConsumed, indexInTx, EventTypeEnum.Others.type(), contractAddress, payer, calledContractHash);
+ blockTime, indexInBlock, confirmFlag, ConstantParam.EMPTY, gasConsumed, indexInTx, EventTypeEnum.Others.type(), contractHash, payer, calledContractHash);
ConstantParam.BATCHBLOCKDTO.getTxDetails().add(txDetail);
ConstantParam.BATCHBLOCKDTO.getTxDetailDailys().add(TxDetail.toTxDetailDaily(txDetail));
}
diff --git a/back-end-projects/OntSynHandler/src/main/resources/mapper/TxDetailIndexMapper.xml b/back-end-projects/OntSynHandler/src/main/resources/mapper/TxDetailIndexMapper.xml
index 9446a0a2..7b1f79e1 100644
--- a/back-end-projects/OntSynHandler/src/main/resources/mapper/TxDetailIndexMapper.xml
+++ b/back-end-projects/OntSynHandler/src/main/resources/mapper/TxDetailIndexMapper.xml
@@ -4,8 +4,8 @@
INSERT INTO tbl_tx_detail_index
- (address, desc_block_height, tx_hash, tx_index, called_contract_hash, tx_time, asset_name, tx_direction)
- SELECT from_address, (~0 >> 33) - block_height, tx_hash, tx_index, called_contract_hash, tx_time, asset_name, 0
+ (address, desc_block_height, tx_hash, block_index, tx_index, called_contract_hash, tx_time, asset_name, tx_direction)
+ SELECT from_address, (~0 >> 33) - block_height, tx_hash, block_index, tx_index, called_contract_hash, tx_time, asset_name, 0
FROM tbl_tx_detail
WHERE block_height BETWEEN #{beginHeight} AND #{endHeight} AND from_address <> '' AND event_type IN (2, 3)
@@ -17,8 +17,8 @@
INSERT INTO tbl_tx_detail_index
- (address, desc_block_height, tx_hash, tx_index, called_contract_hash, tx_time, asset_name, tx_direction)
- SELECT to_address, (~0 >> 33) - block_height, tx_hash, tx_index, called_contract_hash, tx_time, asset_name, 1
+ (address, desc_block_height, tx_hash, block_index, tx_index, called_contract_hash, tx_time, asset_name, tx_direction)
+ SELECT to_address, (~0 >> 33) - block_height, tx_hash, block_index, tx_index, called_contract_hash, tx_time, asset_name, 1
FROM tbl_tx_detail
WHERE block_height BETWEEN #{beginHeight} AND #{endHeight} AND to_address <> '' AND event_type IN (2, 3)