Skip to content

Commit 00da601

Browse files
committed
feat: using new tx service and delete old
1 parent 1dcf5e1 commit 00da601

10 files changed

Lines changed: 21 additions & 694 deletions

File tree

packages/neuron-wallet/src/controllers/transactions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { Transaction } from '../types/cell-types'
2-
import TransactionsService, { PaginationResult, TransactionsByLockHashesParam } from '../services/transactions'
2+
import TransactionsService, {
3+
PaginationResult,
4+
TransactionsByLockHashesParam,
5+
} from '../services/tx/transaction-service'
36

47
import AddressesService from '../services/addresses'
58
import WalletsService from '../services/wallets'

packages/neuron-wallet/src/database/address/dao.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { Not, In } from 'typeorm'
22
import AddressEntity, { AddressVersion } from './entities/address'
33
import { AddressType } from '../../models/keys/address'
44
import { getConnection } from './ormconfig'
5-
import TransactionsService, { OutputStatus } from '../../services/transactions'
5+
import TransactionsService from '../../services/tx/transaction-service'
66
import CellsService from '../../services/cells'
77
import LockUtils from '../../models/lock-utils'
88
import { TransactionStatus } from '../../types/cell-types'
9+
import { OutputStatus } from '../../services/tx/params'
910

1011
export interface Address {
1112
walletId: string

packages/neuron-wallet/src/database/chain/migrations/1562038960990-AddStatusToTx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {MigrationInterface, QueryRunner, TableColumn, getConnection} from "typeorm";
22
import TransactionEntity from '../entities/transaction'
3-
import { OutputStatus } from '../../../services/transactions'
3+
import { OutputStatus } from '../../../services/tx/params'
44
import { TransactionStatus } from '../../../types/cell-types'
55

66
export class AddStatusToTx1562038960990 implements MigrationInterface {

packages/neuron-wallet/src/listeners/tx-status.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { remote } from 'electron'
22
import { interval } from 'rxjs'
3-
import TransactionsService from '../services/transactions'
43
import { TransactionStatus } from '../types/cell-types'
54
import LockUtils from '../models/lock-utils'
65
import AddressesUsedSubject from '../models/subjects/addresses-used-subject'
6+
import FailedTransaction from '../services/tx/failed-transaction'
77

88
const { nodeService } = remote.require('./startup/sync-block-task/params')
99

@@ -21,7 +21,7 @@ const getTransactionStatus = async (hash: string) => {
2121
}
2222

2323
const trackingStatus = async () => {
24-
const pendingTransactions = await TransactionsService.pendings()
24+
const pendingTransactions = await FailedTransaction.pendings()
2525
if (!pendingTransactions.length) {
2626
return
2727
}
@@ -39,7 +39,7 @@ const trackingStatus = async () => {
3939
if (!failedTxs.length) {
4040
return
4141
}
42-
const blake160s = await TransactionsService.updateFailedTxs(failedTxs.map(tx => tx.hash))
42+
const blake160s = await FailedTransaction.updateFailedTxs(failedTxs.map(tx => tx.hash))
4343
const usedAddresses = blake160s.map(blake160 => LockUtils.blake160ToAddress(blake160))
4444
AddressesUsedSubject.getSubject().next(usedAddresses)
4545
}

packages/neuron-wallet/src/services/cells.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getConnection, In } from 'typeorm'
22
import OutputEntity from '../database/chain/entities/output'
33
import { Cell, OutPoint, Input } from '../types/cell-types'
44
import { CapacityNotEnough } from '../exceptions'
5-
import { OutputStatus } from './transactions'
5+
import { OutputStatus } from './tx/params'
66

77
export const MIN_CELL_CAPACITY = '6000000000'
88

packages/neuron-wallet/src/services/sync/check-and-save/tx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getConnection } from 'typeorm'
22
import { Subject } from 'rxjs'
33
import { Transaction, Cell, OutPoint } from '../../../types/cell-types'
44
import OutputEntity from '../../../database/chain/entities/output'
5-
import TransactionsService from '../../transactions'
5+
import SaveTransaction from '../../tx/save-transaction'
66
import CheckOutput from './output'
77
import LockUtils from '../../../models/lock-utils'
88
import { addressesUsedSubject as addressesUsedSubjectParam } from '../renderer-params'
@@ -32,7 +32,7 @@ export default class CheckTx {
3232
public checkAndSave = async (lockHashes: string[]): Promise<boolean> => {
3333
const addresses = await this.check(lockHashes)
3434
if (addresses.length > 0) {
35-
await TransactionsService.saveFetchTx(this.tx)
35+
await SaveTransaction.saveFetchTx(this.tx)
3636
this.addressesUsedSubject.next(addresses)
3737
return true
3838
}

packages/neuron-wallet/src/services/sync/queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Block, BlockHeader } from '../../types/cell-types'
33
import RangeForCheck from './range-for-check'
44
import BlockNumber from './block-number'
55
import Utils from './utils'
6-
import TransactionsService from '../transactions'
76
import QueueAdapter from './queue-adapter'
7+
import SaveTransaction from '../tx/save-transaction'
88

99
export default class Queue {
1010
private q: any
@@ -106,7 +106,7 @@ export default class Queue {
106106
const rangeFirstBlockHeader: BlockHeader = range[0]
107107
await this.currentBlockNumber.updateCurrent(BigInt(rangeFirstBlockHeader.number))
108108
await this.rangeForCheck.setRange([])
109-
await TransactionsService.deleteWhenFork(rangeFirstBlockHeader.number)
109+
await SaveTransaction.deleteWhenFork(rangeFirstBlockHeader.number)
110110
await this.cleanQueue()
111111
this.startBlockNumber = await this.currentBlockNumber.getCurrent()
112112
this.batchPush()

0 commit comments

Comments
 (0)