This commit is contained in:
aozhiwei 2023-07-12 20:41:53 +08:00
parent b846141d7f
commit f623f77e1b

View File

@ -47,7 +47,7 @@ class PullBcEvent extends BaseService {
} }
async pullEvent() { async pullEvent() {
const logHead = this.getInstanceName() + ' pullEvent: '; const logHead = this.genLogHead(' pullEvent: ');
while (true) { while (true) {
await this.bc.lockQuery(); await this.bc.lockQuery();
try { try {
@ -103,7 +103,7 @@ class PullBcEvent extends BaseService {
} }
async getFromBlock() { async getFromBlock() {
const logHead = this.getInstanceName() + ' getFromBlock: '; const logHead = this.genLogHead(' getFromBlock: ');
const firstBlockNumber = this.getInitBlock(); const firstBlockNumber = this.getInitBlock();
while (this.lastBlockNumber < 1) { while (this.lastBlockNumber < 1) {
try { try {
@ -151,7 +151,7 @@ class PullBcEvent extends BaseService {
} }
async saveLastBlockNumber(blockNumber) { async saveLastBlockNumber(blockNumber) {
const logHead = this.getInstanceName() + ' event_process.saveLastBlockNumber: '; const logHead = this.genLogHead(' event_process.saveLastBlockNumber: ');
while (true) { while (true) {
const {err} = await this.conn.upsert( const {err} = await this.conn.upsert(
't_last_block', 't_last_block',
@ -184,7 +184,7 @@ class PullBcEvent extends BaseService {
} }
async saveToDb(event) { async saveToDb(event) {
const logHead = this.getInstanceName() + ' event_process.saveToDb: '; const logHead = this.genLogHead(' event_process.saveToDb: ');
while (true) { while (true) {
const nowTime = utils.getUtcTime(); const nowTime = utils.getUtcTime();
const returnValues = event['returnValues']; const returnValues = event['returnValues'];
@ -247,9 +247,10 @@ class PullBcEvent extends BaseService {
return this.eventConf['contract_name']; return this.eventConf['contract_name'];
} }
getInstanceName() { genLogHead(msg) {
const instName = this.getNetId() + '.' + this.getContractName() + '.' + this.getEventName(); const logHead = this.getNetId() + ' ' + this.getContractName() + '.' +
return instName; this.getEventName() + ' pull_bcevent ' + msg;
return logHead;
} }
} }