From 95dedd8d6ae3404fa20a53ee91e3a847ac3731fa Mon Sep 17 00:00:00 2001 From: yanguoyu <841185308@qq.com> Date: Fri, 17 Nov 2023 15:38:15 +0800 Subject: [PATCH] fix: Add message send to avoid the tx db has not submit finish yet. --- .../src/block-sync-renderer/sync/light-connector.ts | 6 +++--- .../neuron-wallet/src/block-sync-renderer/sync/queue.ts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/light-connector.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/light-connector.ts index 3ea2fb05ec..5e546d673b 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/light-connector.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/light-connector.ts @@ -248,14 +248,14 @@ export default class LightConnector extends Connector { .createBatchRequest<'getTransaction', string[], TransactionWithStatus[]>(txHashes.map(v => ['getTransaction', v])) .exec() const previousTxHashes = new Set() - transactions.forEach(tx => { - tx.transaction.inputs.forEach(input => { + transactions + .flatMap(tx => tx.transaction.inputs) + .forEach(input => { const previousTxHash = input.previousOutput!.txHash if (previousTxHash !== `0x${'0'.repeat(64)}`) { previousTxHashes.add(previousTxHash) } }) - }) await this.lightRpc.createBatchRequest([...previousTxHashes].map(v => ['fetchTransaction' as keyof Base, v])).exec() } diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts index 66b9cbc4a9..e53df531d4 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts @@ -90,6 +90,7 @@ export default class Queue { while (true) { try { await this.#checkAndSave(txHashes) + process.send?.({ channel: 'tx-db-changed' }) break } catch (error) { logger.error('retry saving transactions in 2 seconds due to error:', error)