From fa8350ec7c4f3fbaf6f58139913950178b3d8807 Mon Sep 17 00:00:00 2001 From: Cryptcoin Junkey Date: Thu, 16 Sep 2021 05:20:01 +0000 Subject: [PATCH] Use pagenation on getting assets in get_normalized_balances. Signed-off-by: Cryptcoin Junkey --- counterblock/lib/modules/assets.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/counterblock/lib/modules/assets.py b/counterblock/lib/modules/assets.py index a588812..ecd5ff8 100644 --- a/counterblock/lib/modules/assets.py +++ b/counterblock/lib/modules/assets.py @@ -144,9 +144,17 @@ def get_normalized_balances(addresses): filters.append({'field': 'address', 'op': '==', 'value': address}) mappings = {} - result = util.call_jsonrpc_api( - "get_balances", - {'filters': filters, 'filterop': 'or'}, abort_on_error=True)['result'] + result = [] + size = 1000 + step = 0 + while True: + sub = util.call_jsonrpc_api( + "get_balances", + {'filters': filters, 'filterop': 'or', 'limit': size, 'offset': size * step}, abort_on_error=True)['result'] + if len(sub) == 0: + break + result = result + sub + step = step + 1 isowner = {} owned_assets = config.mongo_db.tracked_assets.find(