Update device in storage only when we found a transaction

This commit is contained in:
Sosthene 2024-10-12 15:07:14 +02:00
parent 755828c495
commit 9f45b2c788
2 changed files with 10 additions and 7 deletions

View File

@ -209,16 +209,21 @@ export default class Services {
async parseNewTx(tx: string) {
try {
console.log('==============> sending txxxxxxx parser', tx)
// console.log('==============> sending txxxxxxx parser', tx)
const services = await Services.getInstance();
const parsedTx = await services.sdkClient.parse_new_tx(tx, 0, 0.01)
console.log("🚀 ~ Services ~ parseNewTx ~ parsedTx:", parsedTx)
if(parsedTx) {
await this.handleApiReturn(parsedTx)
// await this.saveTxToDb(parsedTx)
console.log("🚀 ~ Services ~ parseNewTx ~ parsedTx:", parsedTx)
try {
await this.handleApiReturn(parsedTx);
const newDevice = await this.dumpDevice();
await services.saveDevice(newDevice);
} catch (e) {
console.error("Failed to update device with new tx");
}
}
} catch(e) {
console.log(e)
console.trace('Not our transaction');
}
}

View File

@ -48,8 +48,6 @@ class WebSocketClient {
switch(parsedMessage.flag) {
case 'NewTx':
await services.parseNewTx(parsedMessage.content)
let device = await services.dumpDevice()
await services.saveDevice(device)
break;
case 'Cipher':
await services.parseCipher(parsedMessage.content)