This commit is contained in:
aozhiwei 2023-07-05 21:15:26 +08:00
parent 55d4098be7
commit a356500cb1
2 changed files with 44 additions and 0 deletions

View File

@ -215,6 +215,21 @@ function getNetDir(netId) {
return netDir;
}
function getAllTables() {
const tables = {};
getNetList().forEach(
(net) => {
net['Events'].forEach(
(item) => {
tables[item['table_name']] = {
'table_name': item['table_name']
};
}
);
});
return tables;
}
exports.init = init;
exports.getMetaByKey = getMetaByKey;
@ -226,3 +241,4 @@ exports.getWeb3DbSpiderConf = getWeb3DbSpiderConf;
exports.getContractsConf = getContractsConf;
exports.getNetList = getNetList;
exports.getNetDir = getNetDir;
exports.getAllTables = getAllTables;

View File

@ -3,9 +3,37 @@ const utils = require('j7/utils');
const bcutils = require('j7/bcutils');
const log = require('j7/log');
const BaseService = require('./baseservice');
const metaFactory = require('../metadata/factory');
class DbEventProcess extends BaseService {
static #tableMaxIdxHash = {};
static async staticInit() {
console.log(metaFactory.getAllTables());
/*
const {err, conn} = await app.getDbConn('BcEventDb0');
{
const {err, maxIdx} = await conn.getMaxIdx(BCEVENT_TABLE_NAME);
if (err) {
throw 'PullDbEvent error:' + err;
}
PullDbEvent.#maxIdx = maxIdx;
}
const updateMaxIdxFunc = async () => {
while (true) {
const {err, maxIdx} = await conn.getMaxIdx(BCEVENT_TABLE_NAME);
if (!err) {
PullDbEvent.#maxIdx = maxIdx;
await utils.sleep(500 + utils.randRange(500, 1500));
} else {
await utils.sleep(5000 + utils.randRange(500, 1500));
}
}
};
updateMaxIdxFunc();*/
}
async init(net, event) {
const {err, conn} = await app.getDbConn('BcEventDb0');
this.conn = conn;