Skip to content

Commit

Permalink
add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Daryl-L committed May 14, 2024
1 parent 2f7367a commit 3fe81ed
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/services/nervos.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class NervosService {
#indexer: Indexer
#rpc: RPC
#rgbppConfig: RGBPPConfig
#retryTimes = 3

constructor(private readonly _configService: ConfigService) {
const config = this._configService.get<NervosConfig>('nervos')
Expand All @@ -25,8 +26,16 @@ export class NervosService {
return []
}

const txes = await this.#rpc.createBatchRequest(txHashes.map(txHash => (['getTransaction', txHash]))).exec()
return txes
let retryTimes = 0;
while (retryTimes < this.#retryTimes) {
try {
const txes = await this.#rpc.createBatchRequest(txHashes.map(txHash => (['getTransaction', txHash]))).exec()
return txes
} catch (e) {
console.log(e)
retryTimes++
}
}
}

getMappedMultipleTransaction = async (txHashes: HexString[]) => {
Expand Down

0 comments on commit 3fe81ed

Please sign in to comment.