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