1
This commit is contained in:
parent
a4927c82b6
commit
d3deeb5c99
@ -33,7 +33,6 @@ class BlockChain {
|
|||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
this.web3Conf = metaFactory.getWeb3Conf(this.netId);
|
this.web3Conf = metaFactory.getWeb3Conf(this.netId);
|
||||||
console.log(this.web3Conf);
|
|
||||||
this.contractsConf = metaFactory.getContractsConf(this.netId);
|
this.contractsConf = metaFactory.getContractsConf(this.netId);
|
||||||
this.netDir = metaFactory.getNetDir(this.netId);
|
this.netDir = metaFactory.getNetDir(this.netId);
|
||||||
|
|
||||||
@ -95,6 +94,10 @@ class BlockChain {
|
|||||||
return contract;
|
return contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCurrBlockNumber() {
|
||||||
|
return this.currBlockNumber;
|
||||||
|
}
|
||||||
|
|
||||||
async lockQuery() {
|
async lockQuery() {
|
||||||
while (this.queryLockTimes > 3) {
|
while (this.queryLockTimes > 3) {
|
||||||
await utils.sleep(100 + utils.randRange(10, 100));
|
await utils.sleep(100 + utils.randRange(10, 100));
|
||||||
|
@ -117,6 +117,8 @@ async function init() {
|
|||||||
const netId = net['net_id'];
|
const netId = net['net_id'];
|
||||||
const netDir = configDir + 'nets/' + netId + '/';
|
const netDir = configDir + 'nets/' + netId + '/';
|
||||||
web3ConfHash[netId] = {
|
web3ConfHash[netId] = {
|
||||||
|
'net_id': netId,
|
||||||
|
'netId': netId,
|
||||||
'Web3': utils.readJsonFromFile(netDir + 'web3.json'),
|
'Web3': utils.readJsonFromFile(netDir + 'web3.json'),
|
||||||
'Contract': utils.readJsonFromFile(netDir + 'contract.json'),
|
'Contract': utils.readJsonFromFile(netDir + 'contract.json'),
|
||||||
'Events': net['events'],
|
'Events': net['events'],
|
||||||
|
@ -19,13 +19,13 @@ class BlockChain extends BaseService {
|
|||||||
|
|
||||||
static async staticInit() {
|
static async staticInit() {
|
||||||
metaFactory.getNetList().forEach(async (net) => {
|
metaFactory.getNetList().forEach(async (net) => {
|
||||||
const bc = new bcClass(net['net_id']);
|
const bc = new bcClass(net['netId']);
|
||||||
netIdHash[net['net_id']] = bc;
|
netIdHash[net['netId']] = bc;
|
||||||
await bc.init();
|
await bc.init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(netId) {
|
init(netId) {
|
||||||
this.#bc = getBc(netId);
|
this.#bc = getBc(netId);
|
||||||
return this.#bc != null;
|
return this.#bc != null;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class PullBcEvent extends BaseService {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.log(err);
|
log.error(err);
|
||||||
}
|
}
|
||||||
await utils.sleep(5000 + utils.randRange(500, 1500));
|
await utils.sleep(5000 + utils.randRange(500, 1500));
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ class BcSpider extends BaseTask {
|
|||||||
|
|
||||||
createPullBcEventService(net, event) {
|
createPullBcEventService(net, event) {
|
||||||
const bc = serviceFactory.create('BlockChain');
|
const bc = serviceFactory.create('BlockChain');
|
||||||
|
bc.init(net['net_id']);
|
||||||
const pullBcEventService = serviceFactory.create('PullBcEvent');
|
const pullBcEventService = serviceFactory.create('PullBcEvent');
|
||||||
event['pullBcEventService'] = pullBcEventService;
|
event['pullBcEventService'] = pullBcEventService;
|
||||||
pullBcEventService.init(bc, net, event);
|
pullBcEventService.init(bc, net, event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user