Skip to content

Commit

Permalink
fix: Add message send to avoid the tx db has not submit finish yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Nov 17, 2023
1 parent ea04f42 commit 95dedd8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ export default class LightConnector extends Connector<CKBComponents.Hash> {
.createBatchRequest<'getTransaction', string[], TransactionWithStatus[]>(txHashes.map(v => ['getTransaction', v]))
.exec()
const previousTxHashes = new Set<string>()
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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 95dedd8

Please sign in to comment.