1
This commit is contained in:
parent
ac6f735c1a
commit
2dd4b9ec20
@ -1,23 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"instance_id" : 1,
|
"instance_id" : 1,
|
||||||
"listen_port": 8692,
|
"listen_port": 8692
|
||||||
"nets": [
|
|
||||||
{
|
|
||||||
"net_id": 421613,
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"contract_name": "HERO",
|
|
||||||
"event_name": "Transfer",
|
|
||||||
"init_block": 24792980
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"contract_name": "CHIP",
|
|
||||||
"event_name": "Transfer",
|
|
||||||
"init_block": 26982576
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -10,67 +10,6 @@ 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.createPullBcEventService(net, event);
|
|
||||||
});
|
|
||||||
this.outputProgressInfo(net, events);
|
|
||||||
}
|
|
||||||
|
|
||||||
createPullBcEventService(net, event) {
|
|
||||||
const bc = serviceFactory.create('BlockChain');
|
|
||||||
bc.init(net['net_id']);
|
|
||||||
const pullBcEventService = serviceFactory.create('PullBcEvent');
|
|
||||||
event['pullBcEventService'] = pullBcEventService;
|
|
||||||
pullBcEventService.init(bc, net, event);
|
|
||||||
return pullBcEventService;
|
|
||||||
}
|
|
||||||
|
|
||||||
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