From 8de8279250be54c100c81080afc5b767b4a08879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 31 Oct 2022 20:00:35 +0000 Subject: [PATCH] fix: prevent the poller to crash when parsing unconfigured coins --- lib/graphql/resolvers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/graphql/resolvers.js b/lib/graphql/resolvers.js index 1c5564b8..2502f50a 100644 --- a/lib/graphql/resolvers.js +++ b/lib/graphql/resolvers.js @@ -198,7 +198,10 @@ const dynamicConfig = ({ deviceId, operatorId, pid, pq, settings, }) => { _.toPairs, /* [[cryptoCode, { balance, ask, bid, cashIn, cashOut }], ...] => [{ cryptoCode, balance, ask, bid, cashIn, cashOut }, ...] */ - _.map(([cryptoCode, obj]) => _.set('cryptoCode', cryptoCode, obj)) + _.map(([cryptoCode, obj]) => _.set('cryptoCode', cryptoCode, obj)), + + /* Only send coins which have all information needed by the machine. This prevents the machine going down if there's an issue with the coin node */ + _.filter(coin => ['ask', 'bid', 'balance', 'cashIn', 'cashOut', 'cryptoCode'].every(it => it in coin)) )(_.concat(balances, coins)) }),