This commit is contained in:
aozhiwei 2023-07-03 22:30:36 +08:00
parent a4927c82b6
commit d3deeb5c99
5 changed files with 11 additions and 5 deletions

View File

@ -33,7 +33,6 @@ class BlockChain {
async init() {
this.web3Conf = metaFactory.getWeb3Conf(this.netId);
console.log(this.web3Conf);
this.contractsConf = metaFactory.getContractsConf(this.netId);
this.netDir = metaFactory.getNetDir(this.netId);
@ -95,6 +94,10 @@ class BlockChain {
return contract;
}
getCurrBlockNumber() {
return this.currBlockNumber;
}
async lockQuery() {
while (this.queryLockTimes > 3) {
await utils.sleep(100 + utils.randRange(10, 100));

View File

@ -117,6 +117,8 @@ async function init() {
const netId = net['net_id'];
const netDir = configDir + 'nets/' + netId + '/';
web3ConfHash[netId] = {
'net_id': netId,
'netId': netId,
'Web3': utils.readJsonFromFile(netDir + 'web3.json'),
'Contract': utils.readJsonFromFile(netDir + 'contract.json'),
'Events': net['events'],

View File

@ -19,13 +19,13 @@ class BlockChain extends BaseService {
static async staticInit() {
metaFactory.getNetList().forEach(async (net) => {
const bc = new bcClass(net['net_id']);
netIdHash[net['net_id']] = bc;
const bc = new bcClass(net['netId']);
netIdHash[net['netId']] = bc;
await bc.init();
});
}
async init(netId) {
init(netId) {
this.#bc = getBc(netId);
return this.#bc != null;
}

View File

@ -104,7 +104,7 @@ class PullBcEvent extends BaseService {
}
continue;
} catch (err) {
log.log(err);
log.error(err);
}
await utils.sleep(5000 + utils.randRange(500, 1500));
}

View File

@ -41,6 +41,7 @@ class BcSpider extends BaseTask {
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);