1
This commit is contained in:
parent
9c0b633dc9
commit
ff55e15735
@ -26,7 +26,7 @@ class PullBcEvent extends BaseService {
|
||||
}
|
||||
|
||||
async pullEvent() {
|
||||
const logClass = this.getInstanceName() + ' pullEvent:';
|
||||
const logHead = this.getInstanceName() + ' pullEvent:';
|
||||
while (true) {
|
||||
await this.bc.lockQuery();
|
||||
try {
|
||||
@ -46,7 +46,7 @@ class PullBcEvent extends BaseService {
|
||||
++this.progInfo['pullCount'];
|
||||
return;
|
||||
} catch (err) {
|
||||
log.error(logClass + err);
|
||||
log.error(logHead + err);
|
||||
await utils.sleep(1000 + utils.randRange(10, 2000));
|
||||
} finally {
|
||||
await this.bc.unlockQuery();
|
||||
@ -78,7 +78,7 @@ class PullBcEvent extends BaseService {
|
||||
}
|
||||
|
||||
async getFromBlock() {
|
||||
const logClass = this.getInstanceName() + ' getFromBlock:';
|
||||
const logHead = this.getInstanceName() + ' getFromBlock:';
|
||||
const firstBlockNumber = this.getInitBlock();
|
||||
while (this.lastBlockNumber < 1) {
|
||||
try {
|
||||
@ -97,7 +97,7 @@ class PullBcEvent extends BaseService {
|
||||
this.lastBlockNumber = firstBlockNumber;
|
||||
}
|
||||
}
|
||||
console.log(logClass, this.lastBlockNumber, this.bc.getCurrBlockNumber());
|
||||
console.log(logHead, this.lastBlockNumber, this.bc.getCurrBlockNumber());
|
||||
while (this.lastBlockNumber + 8 > this.bc.getCurrBlockNumber()) {
|
||||
await utils.sleep(1000 + utils.randRange(500, 1500));
|
||||
}
|
||||
@ -125,7 +125,7 @@ class PullBcEvent extends BaseService {
|
||||
}
|
||||
|
||||
async saveLastBlockNumber(blockNumber) {
|
||||
const logClass = 'event_process.saveLastBlockNumber';
|
||||
const logHead = 'event_process.saveLastBlockNumber';
|
||||
while (true) {
|
||||
const {err} = await this.conn.upsert(
|
||||
't_parameter',
|
||||
@ -143,14 +143,14 @@ class PullBcEvent extends BaseService {
|
||||
if (!err) {
|
||||
break;
|
||||
}
|
||||
log.error(logClass + err);
|
||||
log.error(logHead + err);
|
||||
await utils.sleep(5000 + utils.randRange(500, 1500));
|
||||
}
|
||||
this.lastBlockNumber = blockNumber;
|
||||
}
|
||||
|
||||
async saveToDb(event) {
|
||||
const logClass = 'event_process.saveToDb';
|
||||
const logHead = 'event_process.saveToDb';
|
||||
while (true) {
|
||||
const nowTime = utils.getUtcTime();
|
||||
const returnValues = event['returnValues'];
|
||||
@ -179,7 +179,7 @@ class PullBcEvent extends BaseService {
|
||||
if (!err) {
|
||||
break;
|
||||
}
|
||||
log.error(logClass + err);
|
||||
log.error(logHead + err);
|
||||
await utils.sleep(5000 + utils.randRange(500, 1500));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user