1
This commit is contained in:
parent
e36f23ec19
commit
3cf7b36e8c
@ -39,10 +39,10 @@ class PullDbEvent extends BaseService {
|
|||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
this.net = net;
|
this.net = net;
|
||||||
this.event = event;
|
this.event = event;
|
||||||
this.lastIdx = BigInt(0);
|
|
||||||
this.eventConf = this.event['eventConf'];
|
this.eventConf = this.event['eventConf'];
|
||||||
this.progInfo = this.event['progressInfo'];
|
this.progInfo = this.event['progressInfo'];
|
||||||
this.contractAddress = this.net.getContractAddressByName(this.getContractName());
|
this.contractAddress = this.net.getContractAddressByName(this.getContractName());
|
||||||
|
this.lastIdx = await this.getLastIdx();
|
||||||
this.progInfo['lastIdx'] = this.lastIdx.toString();
|
this.progInfo['lastIdx'] = this.lastIdx.toString();
|
||||||
await this.start();
|
await this.start();
|
||||||
}
|
}
|
||||||
@ -129,6 +129,29 @@ class PullDbEvent extends BaseService {
|
|||||||
return this.eventConf['table_name'];
|
return this.eventConf['table_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getLastIdx() {
|
||||||
|
const logHead = this.getInstanceName() + ' getLastIdx: ';
|
||||||
|
while (true) {
|
||||||
|
const {err, row} = await this.conn.ormSelectOne(
|
||||||
|
't_dbpull_last_idx',
|
||||||
|
[
|
||||||
|
['net_id', this.getNetId()],
|
||||||
|
['contract_address', this.getContractAddress()],
|
||||||
|
['event_name', this.getEventName()],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if (err) {
|
||||||
|
log.error(logHead + err);
|
||||||
|
await utils.sleep(5000 + utils.randRange(500, 1500));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (row) {
|
||||||
|
return BigInt(row['last_idx']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BigInt(0);
|
||||||
|
}
|
||||||
|
|
||||||
async saveLastIdx(lastIdx) {
|
async saveLastIdx(lastIdx) {
|
||||||
const logHead = this.getInstanceName() + ' saveLastIdx: ';
|
const logHead = this.getInstanceName() + ' saveLastIdx: ';
|
||||||
while (true) {
|
while (true) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user