From 7724df25cc8467d06a4e93404a18bde73bb430fa Mon Sep 17 00:00:00 2001 From: Maxim Shishmarev Date: Thu, 9 Jul 2020 18:11:40 +1000 Subject: [PATCH] Fix incorrect handling of pow update --- ts/session/snode_api/serviceNodeAPI.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ts/session/snode_api/serviceNodeAPI.ts b/ts/session/snode_api/serviceNodeAPI.ts index c7f20c261..2742fa9a4 100644 --- a/ts/session/snode_api/serviceNodeAPI.ts +++ b/ts/session/snode_api/serviceNodeAPI.ts @@ -300,11 +300,15 @@ export async function storeOnNode( const res = snodeRes as any; + const json = JSON.parse(snodeRes.body); // Make sure we aren't doing too much PoW const currentDifficulty = window.storage.get('PoWDifficulty', null); - if (res && res.difficulty && res.difficulty !== currentDifficulty) { - window.storage.put('PoWDifficulty', res.difficulty); - // should we return false? + if ( + json && + json.difficulty && + json.difficulty !== parseInt(currentDifficulty, 10) + ) { + window.storage.put('PoWDifficulty', json.difficulty); } return true; } catch (e) {