1
This commit is contained in:
parent
e5806b12d2
commit
e5ac1163c4
50
server/web3dbspider/services/dbevent_process.js
Normal file
50
server/web3dbspider/services/dbevent_process.js
Normal file
@ -0,0 +1,50 @@
|
||||
const app = require('j7/app');
|
||||
const utils = require('j7/utils');
|
||||
const bcutils = require('j7/bcutils');
|
||||
const log = require('j7/log');
|
||||
const BaseService = require('./baseservice');
|
||||
|
||||
class DbEventProcess extends BaseService {
|
||||
|
||||
async init(net, event) {
|
||||
const {err, conn} = await app.getDbConn('BcEventDb0');
|
||||
this.conn = conn;
|
||||
this.net = net;
|
||||
this.event = event;
|
||||
this.lastIdx = BigInt(0);
|
||||
this.eventConf = this.event['eventConf'];
|
||||
this.progInfo = this.event['progressInfo'];
|
||||
await this.start();
|
||||
}
|
||||
|
||||
async start() {
|
||||
while (true) {
|
||||
await this.pullEvent();
|
||||
await utils.sleep(500 + utils.randRange(500, 1500));
|
||||
}
|
||||
}
|
||||
|
||||
async pullEvent() {
|
||||
const logHead = this.getInstanceName() + ' pullEvent: ';
|
||||
}
|
||||
|
||||
getEventName() {
|
||||
return this.eventConf['event_name'];
|
||||
}
|
||||
|
||||
getContractAddress() {
|
||||
//return this.bc.getContractAddressByName(this.getContractName());
|
||||
}
|
||||
|
||||
getContractName() {
|
||||
return this.eventConf['contract_name'];
|
||||
}
|
||||
|
||||
getInstanceName() {
|
||||
const instName = this.getNetId() + '.' + this.getContractName() + '.' + this.getEventName();
|
||||
return instName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = DbEventProcess;
|
@ -23,7 +23,8 @@ async function addSingle(clsName, modName) {
|
||||
|
||||
async function init() {
|
||||
await add("BlockChain", 'blockchain');
|
||||
add(['PullDbEvent'], 'pull_dbevent');
|
||||
await add(['PullDbEvent'], 'pull_dbevent');
|
||||
await add(['DbEventProcess'], 'dbevent_process');
|
||||
}
|
||||
|
||||
function create(name, session = null) {
|
||||
|
@ -11,6 +11,7 @@ class PullDbEvent extends BaseService {
|
||||
this.conn = conn;
|
||||
this.net = net;
|
||||
this.event = event;
|
||||
this.lastIdx = BigInt(0);
|
||||
this.eventConf = this.event['eventConf'];
|
||||
this.progInfo = this.event['progressInfo'];
|
||||
await this.start();
|
||||
|
@ -43,6 +43,13 @@ class DbSpider extends BaseTask {
|
||||
return pullDbEventService;
|
||||
}
|
||||
|
||||
createDbEventProcessService(net, event) {
|
||||
const DbEventProcessService = serviceFactory.create('DbEventProcess');
|
||||
event['DbEventProcessService'] = DbEventProcessService;
|
||||
DbEventProcessService.init(net, event);
|
||||
return DbEventProcessService;
|
||||
}
|
||||
|
||||
async outputProgressInfo(net, events) {
|
||||
let count = 0;
|
||||
while (true) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user