fix bug
This commit is contained in:
parent
eda5df70c0
commit
9fe1ea98d6
@ -6,8 +6,14 @@ const AbortController = globalThis.AbortController
|
||||
const request = async (url: string, options: any) => {
|
||||
const controller = new AbortController()
|
||||
const timeout = setTimeout(() => controller.abort(), 30000)
|
||||
const res = await fetch(url, { ...options, signal: controller.signal })
|
||||
clearTimeout(timeout)
|
||||
let res;
|
||||
try {
|
||||
res = await fetch(url, { ...options, signal: controller.signal })
|
||||
clearTimeout(timeout)
|
||||
} catch (err) {
|
||||
clearTimeout(timeout)
|
||||
throw err;
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,8 @@ export class NftHolderClass extends BaseModule {
|
||||
const tokenId = event.decodedData.tokenId;
|
||||
const blockNumer = event.blockNumber;
|
||||
const burn = event.decodedData.to === ZERO_ADDRESS
|
||||
const user = (burn ? event.decodedData.from : event.decodedData.to).toLowerCase()
|
||||
let user = (burn ? event.decodedData.from : event.decodedData.to).toLowerCase()
|
||||
user = user.toLowerCase()
|
||||
let record = await NftHolder.findOne({ address, chain, tokenId })
|
||||
if (!record) {
|
||||
record = new NftHolder({ address, chain, tokenId, blockNumber: blockNumer, user, burn })
|
||||
|
@ -28,7 +28,6 @@ export class BlockSyncSvr {
|
||||
}
|
||||
|
||||
async execute() {
|
||||
// try {
|
||||
let currentBlock = await retryEthBlockNumber(this.rpc)
|
||||
let blockStr = await new RedisClient().get(this.redisKey)
|
||||
if (blockStr) {
|
||||
@ -45,9 +44,6 @@ export class BlockSyncSvr {
|
||||
amount: this.batchCount
|
||||
})
|
||||
await this.processBlockDatas(blocks)
|
||||
// } catch (err) {
|
||||
// console.log(err)
|
||||
// }
|
||||
}
|
||||
|
||||
async processBlockDatas(iterator: any) {
|
||||
@ -82,4 +78,4 @@ export class BlockSyncSvr {
|
||||
}
|
||||
return count
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ export class EventBatchSvr {
|
||||
|
||||
async execute() {
|
||||
|
||||
// try {
|
||||
let currentBlock = await retryEthBlockNumber(this.rpc)
|
||||
let toBlock = parseInt(currentBlock.result, 16)
|
||||
let blockStr = await new RedisClient().get(this.redisKey)
|
||||
@ -110,11 +109,6 @@ export class EventBatchSvr {
|
||||
await new RedisClient().set(redisKey, cfg.fromBlock + '')
|
||||
}
|
||||
await new RedisClient().set(this.redisKey, nextBlock + '')
|
||||
|
||||
// } catch (err) {
|
||||
// logger.error('sync events error: ', err.message || err)
|
||||
// throw err
|
||||
// }
|
||||
}
|
||||
|
||||
buildRedisKey(cfg: IEventCfg) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user