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