From e0f6aabebcdbc4a687b2b96822f9d8019c46fe72 Mon Sep 17 00:00:00 2001 From: leej1012 Date: Sun, 4 Feb 2024 15:03:13 +0800 Subject: [PATCH] Add block_index in tbl_tx_detail_index --- .../V1.81__tbl_tx_detail_index_block_index.sql | 3 +++ .../src/main/resources/mapper/TxDetailMapper.xml | 16 ++++++++-------- .../com/github/ontio/thread/TxHandlerThread.java | 12 +++++++----- .../resources/mapper/TxDetailIndexMapper.xml | 8 ++++---- 4 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 back-end-projects/Explorer/src/main/resources/db/migration/V1.81__tbl_tx_detail_index_block_index.sql 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 @@ -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