Adding extra conditions for retrying trx
This commit is contained in:
parent
e0ad7605a4
commit
692352fec6
|
@ -3,8 +3,7 @@
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "embark test",
|
"test": "embark test"
|
||||||
"start": "nodemon server/main.js"
|
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|
|
@ -53,10 +53,7 @@ const isProcessing = async(code) => {
|
||||||
db.defaults({transactions: {}}).write();
|
db.defaults({transactions: {}}).write();
|
||||||
const record = await db.get('transactions.' + code).value();
|
const record = await db.get('transactions.' + code).value();
|
||||||
|
|
||||||
|
return record && record.transactionTimestamp > ((new Date()).getTime() - min3)? true : false;
|
||||||
|
|
||||||
|
|
||||||
return record && record.transactionTimestamp < ((new Date()).getTime() - min3)? true : false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,15 +70,11 @@ const process = async (request) => {
|
||||||
const codeUsed = await contract.methods.codeUsed('0x' + request.code).call();
|
const codeUsed = await contract.methods.codeUsed('0x' + request.code).call();
|
||||||
|
|
||||||
if(sentToAddress || codeUsed){
|
if(sentToAddress || codeUsed){
|
||||||
const message = "Transaction already exists";
|
const message = "Transaction already exists - sentToAddress: " + sentToAddress + " , codeUsed: " +codeUsed;
|
||||||
console.warn(message + " - sentToAddress: " + sentToAddress + " , codeUsed: " +codeUsed);
|
console.warn(message);
|
||||||
return {"error": true, message};
|
return {"error": true, message};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(record);
|
|
||||||
console.log(recordByAddress);
|
|
||||||
|
|
||||||
|
|
||||||
if(record && record.transactionTimestamp > ((new Date()).getTime() - min3) ) {
|
if(record && record.transactionTimestamp > ((new Date()).getTime() - min3) ) {
|
||||||
const message = "Transaction already exists for code: " + request.code;
|
const message = "Transaction already exists for code: " + request.code;
|
||||||
console.warn(message);
|
console.warn(message);
|
||||||
|
|
Loading…
Reference in New Issue