Skip to content

Commit

Permalink
fix: sync stopped in indexer and normal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Sep 26, 2019
1 parent c3bbc73 commit dfa2f1e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions packages/neuron-wallet/src/services/indexer/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ export default class IndexerQueue {
txPoint &&
(BigInt(txPoint.blockNumber) >= startBlockNumber || this.tipBlockNumber - BigInt(txPoint.blockNumber) < 1000)
) {
logger.debug('indexer fetched tx:', type, txPoint.txHash)

const transactionWithStatus = await this.getBlocksService.getTransaction(txPoint.txHash)
const ckbTransaction: CKBComponents.Transaction = transactionWithStatus.transaction
const transaction: Transaction = TypeConvert.toTransaction(ckbTransaction)
Expand Down
13 changes: 7 additions & 6 deletions packages/neuron-wallet/src/services/sync/check-and-save/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export default class CheckAndSave {

public process = async (): Promise<boolean[]> => {
const txs = this.block.transactions
return Promise.all(
txs.map(async tx => {
const checkTx = new CheckTx(tx)
return checkTx.checkAndSave(this.lockHashes)
})
)
let result: boolean[] = []
for (const tx of txs) {
const checkTx = new CheckTx(tx)
const checkResult = await checkTx.checkAndSave(this.lockHashes)
result.push(checkResult)
}
return result
}
}
9 changes: 6 additions & 3 deletions packages/neuron-wallet/src/services/sync/get-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ export default class GetBlocks {
}

public checkAndSave = async (blocks: Block[], lockHashes: string[]) => {
return Utils.mapSeries(blocks, async (block: Block) => {
let checkResult: boolean[][] = []
for (const block of blocks) {
const checkAndSave = new CheckAndSave(block, lockHashes)
return checkAndSave.process()
})
const result = await checkAndSave.process()
checkResult.push(result)
}
return checkResult
}

public retryGetBlock = async (num: string): Promise<Block> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export class TransactionPersistor {
} finally {
await queryRunner.release()
}
tx.inputs = inputs
tx.outputs = outputs
return tx
}

Expand Down

0 comments on commit dfa2f1e

Please sign in to comment.