Skip to content

Commit

Permalink
fix: Fix clear cache with light client.
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Nov 30, 2023
1 parent 106f520 commit 5d6082b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/neuron-wallet/src/database/chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const clean = async (clearAllLightClientData?: boolean) => {
}),
clearAllLightClientData
? getConnection().getRepository(SyncProgress).clear()
: SyncProgressService.clearCurrentWalletProgress(),
: SyncProgressService.clearWalletProgress(),
])
MultisigOutputChangedSubject.getSubject().next('reset')

Expand Down
9 changes: 3 additions & 6 deletions packages/neuron-wallet/src/services/sync-progress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Equal, getConnection, In, LessThan, Not } from 'typeorm'
import { getConnection, In, LessThan, Not } from 'typeorm'
import { computeScriptHash as scriptToHash } from '@ckb-lumos/base/lib/utils'
import SyncProgress, { SyncAddressType } from '../database/chain/entities/sync-progress'
import WalletService from './wallets'
Expand Down Expand Up @@ -119,14 +119,11 @@ export default class SyncProgressService {
.getMany()
}

static async clearCurrentWalletProgress() {
const currentWallet = WalletService.getInstance().getCurrent()
await getConnection().getRepository(SyncProgress).delete({ walletId: currentWallet?.id })
static async clearWalletProgress() {
await getConnection()
.createQueryBuilder()
.update(SyncProgress)
.set({ blockEndNumber: 0, cursor: undefined })
.where({ walletId: Not(Equal(currentWallet?.id)) })
.set({ blockStartNumber: 0, blockEndNumber: 0 })
.execute()
}
}

1 comment on commit 5d6082b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 7045147039

Please sign in to comment.