This commit is contained in:
aozhiwei 2023-06-12 20:05:30 +08:00
parent ee0e02c304
commit 1c485745e5
2 changed files with 11 additions and 5 deletions

View File

@ -41,8 +41,8 @@ class BlockChain {
event.emitEvent(C.BC_INITIALIZED_EVENT);
{
await this.mustBeActive();
const netId = await this.getNetId();
console.log('net_id:', netId, ' blockNumber:', this.getCurrBlockNumber(),
this.netId = await this.asyncGetNetId();
console.log('net_id:', this.getNetId(), ' blockNumber:', this.getCurrBlockNumber(),
' handleRevert:', this.web3.eth.handleRevert, ' isOnlineEnv:', utils.isOnlineEnv());
}
/*let banlances = await this['shardInstance'].methods.balanceOfBatch
@ -58,10 +58,14 @@ class BlockChain {
}
}
async getNetId() {
async asyncGetNetId() {
return await this.web3.eth.getChainId();
}
getNetId() {
return '' + this.netId;
}
async refreshBlockNumber() {
const logClass = 'refreshBlockNumber';
while (true) {
@ -100,7 +104,7 @@ class BlockChain {
const {err, row} = await conn.ormSelectOne(
't_parameter',
[
['name', 'first_block_number.' + await this.getNetId() + '.']
['name', 'first_block_number.' + this.getNetId() + '.']
]
);
if (!err && row) {

View File

@ -6,11 +6,13 @@ const BaseService = require('./baseservice');
class EventProcess extends BaseService {
async init(conn, instance, cb) {
async init(bc, conn, instance, cb) {
this.conn = conn;
this.instance = instance;
this.cb = cb;
this.lastBlockNumber = 0;
this.bc = bc;
this.netId = await this.bc.getNetId();
await this.start();
}