From 613ff7b09cf6b0d2ec1e26624b9571a31916228e Mon Sep 17 00:00:00 2001 From: rdlrt <3169068+rdlrt@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:51:23 +1000 Subject: [PATCH] Couple of chores fixes: 1. active stake cache => epoch_active_stake_cache should populate from scratch on fresh run 2. tx_info => collateral_tx_out.multi_assets_descr cannot be conclusively formatted as JSONB, format them as text array instead --- files/grest/rpc/01_cached_tables/active_stake_cache.sql | 5 ++++- files/grest/rpc/transactions/tx_info.sql | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/files/grest/rpc/01_cached_tables/active_stake_cache.sql b/files/grest/rpc/01_cached_tables/active_stake_cache.sql index 70ef150e..e77dd3eb 100644 --- a/files/grest/rpc/01_cached_tables/active_stake_cache.sql +++ b/files/grest/rpc/01_cached_tables/active_stake_cache.sql @@ -91,7 +91,10 @@ BEGIN epoch_stake.epoch_no, SUM(epoch_stake.amount) AS amount FROM public.epoch_stake - WHERE epoch_stake.epoch_no >= _last_active_stake_validated_epoch + WHERE epoch_stake.epoch_no >= COALESCE( + (SELECT last_value::integer + FROM grest.control_table + WHERE key = 'last_active_stake_validated_epoch'), 0) AND epoch_stake.epoch_no <= _epoch_no GROUP BY epoch_stake.epoch_no ON CONFLICT (epoch_no) DO UPDATE diff --git a/files/grest/rpc/transactions/tx_info.sql b/files/grest/rpc/transactions/tx_info.sql index fd598d23..8161675b 100644 --- a/files/grest/rpc/transactions/tx_info.sql +++ b/files/grest/rpc/transactions/tx_info.sql @@ -276,7 +276,7 @@ BEGIN ) END ) AS reference_script, - REPLACE(tx_out.multi_assets_descr,'fromList ','')::jsonb AS asset_descr + REPLACE(tx_out.multi_assets_descr,'fromList ','')::text AS asset_descr FROM collateral_tx_out AS tx_out INNER JOIN tx ON tx_out.tx_id = tx.id