This commit is contained in:
aozhiwei 2023-07-09 19:21:33 +08:00
parent e105392a3c
commit 89ce413a64

View File

@ -20,34 +20,86 @@ class BcRefresh extends BaseTask {
async initNet(net) { async initNet(net) {
{ {
const events = []; const refreshers = [];
net['refresh_erc721'].forEach net['refresh_erc721'].forEach
( (
(conf721) => { (conf) => {
const event = { const refresher = {
'conf721': conf721, 'conf': conf,
'progressInfo': { 'progressInfo': {
'confirmedCount': 0, 'refreshedCount': 0,
'pendingCount': 0, 'pendingCount': 0,
} }
}; };
events.push(event); refreshers.push(refresher);
this.createPullBcEventService(net, event); this.createErc721Refresher(net, refresher);
}); });
this.outputErc721ProgressInfo(net, events); this.outputProgressInfo(net, refreshers);
}
{
const refreshers = [];
net['refresh_erc1155'].forEach
(
(conf) => {
const refresher = {
'conf': conf,
'progressInfo': {
'refreshedCount': 0,
'pendingCount': 0,
}
};
refreshers.push(refresher);
this.createErc1155Refresher(net, refresher);
});
this.outputProgressInfo(net, refreshers);
}
{
const refreshers = [];
net['refresh_erc20'].forEach
(
(conf) => {
const refresher = {
'conf': conf,
'progressInfo': {
'refreshedCount': 0,
'pendingCount': 0,
}
};
refreshers.push(refresher);
this.createErc20Refresher(net, refresher);
});
this.outputProgressInfo(net, refreshers);
} }
} }
createPullBcEventService(net, event) { createErc721Refresher(net, refresher) {
const bc = serviceFactory.create('BlockChain'); const bc = serviceFactory.create('BlockChain');
bc.init(net['net_id']); bc.init(net['net_id']);
const pullBcEventService = serviceFactory.create('PullBcEvent'); const refresherService = serviceFactory.create('Erc721Refresher');
event['pullBcEventService'] = pullBcEventService; event['refresherService'] = refresherService;
pullBcEventService.init(bc, net, event); refresherService.init(bc, net, event);
return pullBcEventService; return refresherService;
} }
async outputErc721ProgressInfo(net, events) { createErc1155Refresher(net, refresher) {
const bc = serviceFactory.create('BlockChain');
bc.init(net['net_id']);
const refresherService = serviceFactory.create('Erc1155Refresher');
event['refresherService'] = refresherService;
refresherService.init(bc, net, event);
return refresherService;
}
createErc20Refresher(net, refresher) {
const bc = serviceFactory.create('BlockChain');
bc.init(net['net_id']);
const refresherService = serviceFactory.create('Erc20Refresher');
event['refresherService'] = refresherService;
refresherService.init(bc, net, event);
return refresherService;
}
async outputProgressInfo(net, events) {
let count = 0; let count = 0;
while (true) { while (true) {
log.info('----------------------------------------------------------'); log.info('----------------------------------------------------------');