diff --git a/src/hive_fork_manager/app_api.sql b/src/hive_fork_manager/app_api.sql index bea1242e7d95ac63555d14920cc7374b76831354..083a0c5aa6da239330258efe286fd300371a2410 100644 --- a/src/hive_fork_manager/app_api.sql +++ b/src/hive_fork_manager/app_api.sql @@ -882,10 +882,13 @@ CREATE OR REPLACE FUNCTION hive.get_app_current_block_age(_contexts hive.context STABLE AS $BODY$ BEGIN - RETURN now() - (select min(coalesce(hafd.blocks.created_at, to_timestamp(0))) from + RETURN now() - (select min(coalesce(hafd.blocks.created_at, hafd.blocks_reversible.created_at, to_timestamp(0))) from UNNEST(_contexts) AS context_names(name) LEFT JOIN hafd.contexts USING(name) - LEFT JOIN hafd.blocks on num = hafd.contexts.current_block_num); + LEFT JOIN hafd.blocks on hafd.blocks.num = hafd.contexts.current_block_num + LEFT JOIN hafd.blocks_reversible on hafd.blocks_reversible.num = hafd.contexts.current_block_num AND + hafd.blocks_reversible.fork_id = hafd.contexts.fork_id + ); END; $BODY$;