This commit is contained in:
aozhiwei 2023-07-10 20:20:35 +08:00
parent ce0a246f74
commit d6ff05a27c
2 changed files with 40 additions and 3 deletions

View File

@ -47,8 +47,13 @@ class Erc721Refresher extends BaseService {
await utils.serial( await utils.serial(
rows, rows,
async (row) => { async (row) => {
await this.refresh(row); const nftExists = await this.tokenIsExists(row);
--this.progInfo['pendingCount']; if (nftExists) {
await this.refresh(row);
--this.progInfo['pendingCount'];
} else {
++this.progInfo['skipCount'];
}
} }
); );
} else { } else {
@ -56,6 +61,7 @@ class Erc721Refresher extends BaseService {
} }
++this.progInfo['refreshedCount']; ++this.progInfo['refreshedCount'];
this.progInfo['pendingCount'] = 0; this.progInfo['pendingCount'] = 0;
this.progInfo['skipCount'] = 0;
} catch (err) { } catch (err) {
log.error(logHead + err); log.error(logHead + err);
await utils.sleep(5000 + utils.randRange(1000, 3000)); await utils.sleep(5000 + utils.randRange(1000, 3000));
@ -141,6 +147,35 @@ class Erc721Refresher extends BaseService {
return true; return true;
} }
async tokenIsExists(rawRow) {
const {err, nftDbConn} = await app.getDbConn(constant.BCNFTDB_NAME);
if (err) {
log.error('updateConfirmed:' + this.tokenId + ' err:' + err);
return false;
}
try {
{
const {err, row} = await nftDbConn.ormSelectOne(
't_nft',
[
['net_id', rawRow['net_id']],
['token_id', rawRow['token_id']],
['contract_address', rawRow['contract_address']],
]);
if (err) {
log.error('updateConfirmed:' + this.tokenId + ' err:' + err);
return false;
}
if (row) {
return true;
}
}
} finally {
nftDbConn.release();
}
return false;
}
async update(row, fields) { async update(row, fields) {
const {err} = await this.conn.update( const {err} = await this.conn.update(
't_erc721_refresh', 't_erc721_refresh',

View File

@ -29,6 +29,7 @@ class BcRefresh extends BaseTask {
'progressInfo': { 'progressInfo': {
'refreshedCount': 0, 'refreshedCount': 0,
'pendingCount': 0, 'pendingCount': 0,
'skipCount': 0,
} }
}; };
refreshers.push(refresher); refreshers.push(refresher);
@ -116,7 +117,8 @@ class BcRefresh extends BaseTask {
const logObj = 'net_id: ' + net['net_id'] + ' ' + const logObj = 'net_id: ' + net['net_id'] + ' ' +
conf['contract_name'] + '' + conf['contract_name'] + '' +
' refreshedCount:' + progInfo['refreshedCount'] + ' refreshedCount:' + progInfo['refreshedCount'] +
' pendingCount:' + progInfo['pendingCount'] ' pendingCount:' + progInfo['pendingCount'] +
' skipCount:' + progInfo['skipCount']
; ;
log.info(logObj); log.info(logObj);
} }