1
This commit is contained in:
parent
0815fc09fe
commit
735360e079
@ -10,6 +10,67 @@ const metaFactory = require('../metadata/factory');
|
|||||||
class DbSpider extends BaseTask {
|
class DbSpider extends BaseTask {
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
const netList = metaFactory.getNetList();
|
||||||
|
netList.forEach
|
||||||
|
(
|
||||||
|
(net) => {
|
||||||
|
this.initNet(net);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async initNet(net) {
|
||||||
|
const events = [];
|
||||||
|
net['Events'].forEach
|
||||||
|
(
|
||||||
|
(eventConf) => {
|
||||||
|
const event = {
|
||||||
|
'eventConf': eventConf,
|
||||||
|
'progressInfo': {
|
||||||
|
'pullCount': 0,
|
||||||
|
'eventCount': 0,
|
||||||
|
'fromBlock': 0,
|
||||||
|
'toBlock': 0,
|
||||||
|
'currBlock': 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
events.push(event);
|
||||||
|
this.createPullDbEventService(net, event);
|
||||||
|
});
|
||||||
|
this.outputProgressInfo(net, events);
|
||||||
|
}
|
||||||
|
|
||||||
|
createPullDbEventService(net, event) {
|
||||||
|
const bc = serviceFactory.create('BlockChain');
|
||||||
|
bc.init(net['net_id']);
|
||||||
|
const pullDbEventService = serviceFactory.create('PullDbEvent');
|
||||||
|
event['pullDbEventService'] = pullDbEventService;
|
||||||
|
pullDbEventService.init(bc, net, event);
|
||||||
|
return pullDbEventService;
|
||||||
|
}
|
||||||
|
|
||||||
|
async outputProgressInfo(net, events) {
|
||||||
|
let count = 0;
|
||||||
|
while (true) {
|
||||||
|
log.info('----------------------------------------------------------');
|
||||||
|
events.forEach
|
||||||
|
(
|
||||||
|
(event) => {
|
||||||
|
const eventConf = event['eventConf'];
|
||||||
|
const progInfo = event['progressInfo'];
|
||||||
|
const logObj = 'net_id: ' + net['net_id'] + ' ' +
|
||||||
|
eventConf['contract_name'] + '.' +
|
||||||
|
eventConf['event_name'] + ' ' +
|
||||||
|
' pullCount:' + progInfo['pullCount'] +
|
||||||
|
' eventCount:' + progInfo['eventCount'] +
|
||||||
|
' fromBlock:' + progInfo['fromBlock'] +
|
||||||
|
' toBlock:' + progInfo['toBlock'] +
|
||||||
|
' currBlock:' + progInfo['currBlock']
|
||||||
|
;
|
||||||
|
log.info(logObj);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await utils.sleep(1000 * 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user