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