diff --git a/files/grest/rpc/account/account_txs.sql b/files/grest/rpc/account/account_txs.sql index 5f92628..2721c9c 100644 --- a/files/grest/rpc/account/account_txs.sql +++ b/files/grest/rpc/account/account_txs.sql @@ -12,10 +12,20 @@ DECLARE _tx_id_list bigint[]; _stake_address_id integer; BEGIN - SELECT INTO _tx_id_min id - FROM tx - WHERE block_id >= (SELECT id FROM block WHERE block_no >= _after_block_height ORDER BY id limit 1) - ORDER BY id limit 1; + + SELECT INTO _tx_id_min min(id) + FROM tx + WHERE block_id = ( + SELECT id + FROM block AS b + WHERE block_no >= _after_block_height + AND EXISTS ( + SELECT true + FROM tx t + WHERE t.block_id = b.id + ) + ORDER BY id LIMIT 1 + ); SELECT INTO _stake_address_id id FROM stake_address WHERE hash_raw = (SELECT DECODE(b32_decode(_stake_address), 'hex')); diff --git a/files/grest/rpc/address/address_txs.sql b/files/grest/rpc/address/address_txs.sql index 6efb4f5..6e8e9bc 100644 --- a/files/grest/rpc/address/address_txs.sql +++ b/files/grest/rpc/address/address_txs.sql @@ -11,10 +11,19 @@ DECLARE _tx_id_min bigint; _tx_id_list bigint[]; BEGIN - SELECT INTO _tx_id_min id - FROM tx - WHERE block_id >= (SELECT id FROM block WHERE block_no >= _after_block_height ORDER BY id limit 1) - ORDER BY id limit 1; + SELECT INTO _tx_id_min min(id) + FROM tx + WHERE block_id = ( + SELECT id + FROM block AS b + WHERE block_no >= _after_block_height + AND EXISTS ( + SELECT true + FROM tx t + WHERE t.block_id = b.id + ) + ORDER BY id LIMIT 1 + ); -- all tx_out & tx_in tx ids SELECT INTO _tx_id_list ARRAY_AGG(tx_id)