From 4907867165926ada3240b390e27c808c1103324b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E5=9B=BD=E5=AE=87?= <841185308@qq.com> Date: Fri, 12 Jan 2024 08:22:46 +0000 Subject: [PATCH] chore: Remove `address` field from indexer-tx-hash-cache table (#3011) --- .../sync/indexer-cache-service.ts | 4 +--- .../chain/entities/indexer-tx-hash-cache.ts | 10 +--------- ...1704357651876-RemoveAddressInIndexerCache.ts | 17 +++++++++++++++++ .../src/database/chain/ormconfig.ts | 2 ++ .../block-sync-renderer/synchronizer.test.ts | 2 -- 5 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 packages/neuron-wallet/src/database/chain/migrations/1704357651876-RemoveAddressInIndexerCache.ts diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts index 4775f70a67..b58c3d1555 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts @@ -219,13 +219,12 @@ export default class IndexerCacheService { continue } - for (const { lockHash, address } of mappings) { + for (const { lockHash } of mappings) { indexerCaches.push( IndexerTxHashCache.fromObject({ txHash: transaction.hash!, blockNumber: parseInt(transaction.blockNumber!), lockHash, - address, walletId: this.walletId, }) ) @@ -267,7 +266,6 @@ export default class IndexerCacheService { txHash: v.txHash, blockNumber: parseInt(v.blockNumber!), lockHash: v.lockHash, - address: v.address, walletId: v.walletId, }) ) diff --git a/packages/neuron-wallet/src/database/chain/entities/indexer-tx-hash-cache.ts b/packages/neuron-wallet/src/database/chain/entities/indexer-tx-hash-cache.ts index a2b3ce1530..57f998303b 100644 --- a/packages/neuron-wallet/src/database/chain/entities/indexer-tx-hash-cache.ts +++ b/packages/neuron-wallet/src/database/chain/entities/indexer-tx-hash-cache.ts @@ -19,13 +19,6 @@ export default class IndexerTxHashCache extends BaseEntity { @Index() lockHash!: string - @Column({ - type: 'character', - length: 32, - }) - @Index() - address!: string - @Column({ type: 'character', length: 32, @@ -54,12 +47,11 @@ export default class IndexerTxHashCache extends BaseEntity { }) updatedAt!: Date - static fromObject(obj: { txHash: string; blockNumber: number; lockHash: string; address: string; walletId: string }) { + static fromObject(obj: { txHash: string; blockNumber: number; lockHash: string; walletId: string }) { const result = new IndexerTxHashCache() result.txHash = obj.txHash result.blockNumber = obj.blockNumber result.lockHash = obj.lockHash - result.address = obj.address result.walletId = obj.walletId result.isProcessed = false return result diff --git a/packages/neuron-wallet/src/database/chain/migrations/1704357651876-RemoveAddressInIndexerCache.ts b/packages/neuron-wallet/src/database/chain/migrations/1704357651876-RemoveAddressInIndexerCache.ts new file mode 100644 index 0000000000..b6b0dba18c --- /dev/null +++ b/packages/neuron-wallet/src/database/chain/migrations/1704357651876-RemoveAddressInIndexerCache.ts @@ -0,0 +1,17 @@ +import {MigrationInterface, QueryRunner, TableColumn} from "typeorm"; + +export class RemoveAddressInIndexerCache1704357651876 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn('indexer_tx_hash_cache', 'address') + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn('indexer_tx_hash_cache', new TableColumn({ + name: 'address', + type: 'character(32)', + isNullable: false, + })) + } + +} diff --git a/packages/neuron-wallet/src/database/chain/ormconfig.ts b/packages/neuron-wallet/src/database/chain/ormconfig.ts index f7667901a4..9a90ea6be6 100644 --- a/packages/neuron-wallet/src/database/chain/ormconfig.ts +++ b/packages/neuron-wallet/src/database/chain/ormconfig.ts @@ -59,6 +59,7 @@ import { TxLockAddArgs1694746034975 } from './migrations/1694746034975-TxLockAdd import { IndexerTxHashCacheRemoveField1701234043431 } from './migrations/1701234043431-IndexerTxHashCacheRemoveField' import { CreateCellLocalInfo1701234043432 } from './migrations/1701234043432-CreateCellLocalInfo' import { RenameSyncProgress1702781527414 } from './migrations/1702781527414-RenameSyncProgress' +import { RemoveAddressInIndexerCache1704357651876 } from './migrations/1704357651876-RemoveAddressInIndexerCache' export const CONNECTION_NOT_FOUND_NAME = 'ConnectionNotFoundError' @@ -134,6 +135,7 @@ const connectOptions = async (genesisBlockHash: string): Promise { txHash: 'hash1', blockNumber: 10, lockHash: script.computeHash(), - address, walletId, }), ] @@ -165,7 +164,6 @@ describe('unit tests for IndexerConnector', () => { txHash: 'hash2', blockNumber: 2, lockHash: script.computeHash(), - address, walletId, }), ]