修复bchelper重大bug
This commit is contained in:
parent
175fd16c0c
commit
e59b8dae6b
@ -129,12 +129,18 @@ class ContractExecutor {
|
||||
let nowTime = utils.getUtcTime();
|
||||
//要确保100%能unlock
|
||||
let result = null;
|
||||
let gas = 1000000;
|
||||
let timeCost = 0;
|
||||
await bc.lock();
|
||||
try {
|
||||
await bc.mustBeActive();
|
||||
currBlockNumber = bc.getCurrBlockNumber();
|
||||
await this.setPrepareBlockNumber(this.syncLogClass, currBlockNumber, false);
|
||||
nowTime = utils.getUtcTime();
|
||||
result = await this.method(...this.methodArgs).send({gas: 1000000});
|
||||
gas = await this.method(...this.methodArgs).estimateGas({gas: 1000000});
|
||||
result = await this.method(...this.methodArgs).send({gas: gas});
|
||||
timeCost = utils.getUtcTime() - nowTime;
|
||||
log.info('time_cost:' + timeCost + ' gas:' + gas);
|
||||
} catch (err) {
|
||||
hasErr = true;
|
||||
holdErr = err;
|
||||
@ -146,8 +152,9 @@ class ContractExecutor {
|
||||
'prepare',
|
||||
this.getLogKey(),
|
||||
utils.jsonEncode(this.getLogData()),
|
||||
currBlockNumber);
|
||||
await this.setPrepareBlockNumber(this.syncLogClass, currBlockNumber);
|
||||
currBlockNumber,
|
||||
gas,
|
||||
timeCost);
|
||||
if (hasErr) {
|
||||
throw holdErr;
|
||||
}
|
||||
|
@ -36,12 +36,13 @@ class BoxOrder {
|
||||
const getPrepareBlockNumber = () => {
|
||||
return this.orderDb['bc_pay_prepare_block_number'];
|
||||
};
|
||||
const setPrepareBlockNumber = async (logClass, blockNumber) => {
|
||||
const setPrepareBlockNumber = async (logClass, blockNumber, noSuspend = false) => {
|
||||
await this.updateDbMustBeSuccess(
|
||||
logClass,
|
||||
[
|
||||
['bc_pay_prepare_block_number', blockNumber],
|
||||
]
|
||||
],
|
||||
noSuspend
|
||||
);
|
||||
};
|
||||
const getSuccessBlockNumber = () => {
|
||||
@ -151,12 +152,13 @@ class BoxOrder {
|
||||
const getPrepareBlockNumber = () => {
|
||||
return this.orderDb['bc_mint_prepare_block_number' + idx];
|
||||
};
|
||||
const setPrepareBlockNumber = async (logClass, blockNumber) => {
|
||||
const setPrepareBlockNumber = async (logClass, blockNumber, noSuspend = false) => {
|
||||
await this.updateDbMustBeSuccess(
|
||||
logClass,
|
||||
[
|
||||
['bc_mint_prepare_block_number' + idx, blockNumber],
|
||||
]
|
||||
],
|
||||
noSuspend
|
||||
);
|
||||
};
|
||||
const getSuccessBlockNumber = () => {
|
||||
@ -293,7 +295,7 @@ class BoxOrder {
|
||||
}
|
||||
}
|
||||
|
||||
async updateDbMustBeSuccess(logClass, fieldList) {
|
||||
async updateDbMustBeSuccess(logClass, fieldList, noSuspend = false) {
|
||||
const err = await dbhelper.update(
|
||||
't_box_order',
|
||||
[
|
||||
@ -308,7 +310,11 @@ class BoxOrder {
|
||||
err
|
||||
)
|
||||
);
|
||||
await this.suspend(logClass + ' updateDbMustBeSuccess ', err);
|
||||
if (noSuspend) {
|
||||
throw logClass + ' updateDbMustBeSuccess ' + err;
|
||||
} else {
|
||||
await this.suspend(logClass + ' updateDbMustBeSuccess ', err);
|
||||
}
|
||||
} else {
|
||||
fieldList.forEach((val) => {
|
||||
const name = val[0];
|
||||
|
@ -45,12 +45,13 @@ class Present {
|
||||
const getPrepareBlockNumber = () => {
|
||||
return this.presentDb['bc_mint_prepare_block_number'];
|
||||
};
|
||||
const setPrepareBlockNumber = async (logClass, blockNumber) => {
|
||||
const setPrepareBlockNumber = async (logClass, blockNumber, noSuspend = false) => {
|
||||
await this.updateDbMustBeSuccess(
|
||||
logClass,
|
||||
[
|
||||
['bc_mint_prepare_block_number', blockNumber],
|
||||
]
|
||||
],
|
||||
noSuspend
|
||||
);
|
||||
};
|
||||
const getSuccessBlockNumber = () => {
|
||||
@ -185,7 +186,7 @@ class Present {
|
||||
}
|
||||
}
|
||||
|
||||
async updateDbMustBeSuccess(logClass, fieldList) {
|
||||
async updateDbMustBeSuccess(logClass, fieldList, noSuspend = false) {
|
||||
const err = await dbhelper.update(
|
||||
't_present',
|
||||
[
|
||||
@ -200,7 +201,11 @@ class Present {
|
||||
err
|
||||
)
|
||||
);
|
||||
await this.suspend(logClass + ' updateDbMustBeSuccess ', err);
|
||||
if (noSuspend) {
|
||||
throw logClass + ' updateDbMustBeSuccess ' + err;
|
||||
} else {
|
||||
await this.suspend(logClass + ' updateDbMustBeSuccess ', err);
|
||||
}
|
||||
} else {
|
||||
fieldList.forEach((val) => {
|
||||
const name = val[0];
|
||||
@ -243,9 +248,9 @@ class Present {
|
||||
this.presentDb['suspend'] = 1;
|
||||
this.presentDb['suspend_reason'] = '' + reason;
|
||||
await dblog.addLog(
|
||||
'order.suspend',
|
||||
'present.suspend',
|
||||
'',
|
||||
this.getOrderId(),
|
||||
this.getTokenId(),
|
||||
utils.jsonEncode(this.getPresentDb()),
|
||||
'' + reason,
|
||||
logClass
|
||||
|
2
third_party/j7
vendored
2
third_party/j7
vendored
@ -1 +1 @@
|
||||
Subproject commit 29150ac5c02664638c888598f658bf9349918926
|
||||
Subproject commit 6ff510cd95fa5da739a26193043b4b4082d1baa8
|
Loading…
x
Reference in New Issue
Block a user