1
This commit is contained in:
parent
f506ee0169
commit
2e67b1939c
@ -12,6 +12,7 @@ const metaFactory = require('./metadata/factory');
|
||||
class BlockChain {
|
||||
|
||||
constructor(netId) {
|
||||
this.actived = false;
|
||||
this.netId = netId;
|
||||
this.lastQueryTime = utils.getUtcTime();
|
||||
this.queryLockTimes = 0;
|
||||
@ -53,6 +54,18 @@ class BlockChain {
|
||||
this.netId,
|
||||
chainId
|
||||
));
|
||||
{
|
||||
await this.mustBeActive();
|
||||
const netId = this.getNetId();
|
||||
console.log('net_id:', netId, ' blockNumber:', this.getCurrBlockNumber(),
|
||||
' handleRevert:', this.web3.eth.handleRevert, ' isOnlineEnv:', utils.isOnlineEnv());
|
||||
}
|
||||
}
|
||||
|
||||
async mustBeActive() {
|
||||
while (!this.actived) {
|
||||
await utils.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
getNetId() {
|
||||
@ -99,17 +112,13 @@ class BlockChain {
|
||||
}
|
||||
|
||||
async refreshBlockNumber() {
|
||||
const logHead = 'refreshBlockNumber';
|
||||
const logHead = ' refreshBlockNumber:';
|
||||
while (true) {
|
||||
try {
|
||||
this.currBlockNumber = await this.web3.eth.getBlockNumber();
|
||||
this.actived = true;
|
||||
this.lastRefreshTime = utils.getUtcTime();
|
||||
console.log('currBlockNumber', this.currBlockNumber);
|
||||
if (!this.initedBlockNumber) {
|
||||
this.initedBlockNumber = true;
|
||||
this.initBlockNumber = this.currBlockNumber;
|
||||
}
|
||||
} catch (e) {
|
||||
this.actived = false;
|
||||
log.warning(util.format('%s err:%s',
|
||||
|
Loading…
x
Reference in New Issue
Block a user