Update device in storage only when we found a transaction
This commit is contained in:
parent
755828c495
commit
9f45b2c788
@ -209,16 +209,21 @@ export default class Services {
|
|||||||
|
|
||||||
async parseNewTx(tx: string) {
|
async parseNewTx(tx: string) {
|
||||||
try {
|
try {
|
||||||
console.log('==============> sending txxxxxxx parser', tx)
|
// console.log('==============> sending txxxxxxx parser', tx)
|
||||||
const services = await Services.getInstance();
|
const services = await Services.getInstance();
|
||||||
const parsedTx = await services.sdkClient.parse_new_tx(tx, 0, 0.01)
|
const parsedTx = await services.sdkClient.parse_new_tx(tx, 0, 0.01)
|
||||||
console.log("🚀 ~ Services ~ parseNewTx ~ parsedTx:", parsedTx)
|
|
||||||
if(parsedTx) {
|
if(parsedTx) {
|
||||||
await this.handleApiReturn(parsedTx)
|
console.log("🚀 ~ Services ~ parseNewTx ~ parsedTx:", parsedTx)
|
||||||
// await this.saveTxToDb(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) {
|
} catch(e) {
|
||||||
console.log(e)
|
console.trace('Not our transaction');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,6 @@ class WebSocketClient {
|
|||||||
switch(parsedMessage.flag) {
|
switch(parsedMessage.flag) {
|
||||||
case 'NewTx':
|
case 'NewTx':
|
||||||
await services.parseNewTx(parsedMessage.content)
|
await services.parseNewTx(parsedMessage.content)
|
||||||
let device = await services.dumpDevice()
|
|
||||||
await services.saveDevice(device)
|
|
||||||
break;
|
break;
|
||||||
case 'Cipher':
|
case 'Cipher':
|
||||||
await services.parseCipher(parsedMessage.content)
|
await services.parseCipher(parsedMessage.content)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user