1
This commit is contained in:
parent
d8dfd4dd67
commit
cd713ad5fe
@ -6,31 +6,10 @@ const constant = require('common/constant');
|
||||
const dbpool = require('common/dbpool');
|
||||
const BaseService = require('./baseservice');
|
||||
|
||||
let g_bcevent_conn = null;
|
||||
let lock_times = 0;
|
||||
async function getGBcEventConn() {
|
||||
while (lock_times > 0) {
|
||||
await utils.sleep(1);
|
||||
}
|
||||
if (!g_bcevent_conn) {
|
||||
++lock_times;
|
||||
try {
|
||||
const {err, conn} = await app.getDbConn(constant.BCEVENTDB_NAME);
|
||||
if (err) {
|
||||
throw new Error('getGBcEventConn error:' + err);
|
||||
}
|
||||
g_bcevent_conn = conn;
|
||||
} finally {
|
||||
--lock_times;
|
||||
}
|
||||
}
|
||||
return g_bcevent_conn;
|
||||
}
|
||||
|
||||
class PullBcEvent extends BaseService {
|
||||
|
||||
async init(bc, net, event) {
|
||||
this.conn = await getGBcEventConn();
|
||||
this.conn = await dbpool.getBcEventConn(app);
|
||||
this.lastBlockNumber = 0;
|
||||
this.bc = bc;
|
||||
this.net = net;
|
||||
|
Loading…
x
Reference in New Issue
Block a user