From 7ab3e1960b186b6466d520291a1c0a5d6c6defe2 Mon Sep 17 00:00:00 2001 From: Dagur Valberg Johannsson Date: Wed, 13 Nov 2024 10:13:58 +0100 Subject: [PATCH] bug: Fix 'active' pools showing old instance --- src/rpc/pool.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rpc/pool.rs b/src/rpc/pool.rs index 84fa17b..58b56af 100644 --- a/src/rpc/pool.rs +++ b/src/rpc/pool.rs @@ -162,6 +162,7 @@ struct ActivePool { tokens: u64, txid: String, tx_pos: u32, + pool_id: String, } fn db_list_active_pools( @@ -190,10 +191,16 @@ fn db_list_active_pools( phe.token_amount, phe.txid, phe.tx_pos, - p.token_id + p.token_id, + p.creation_utxo FROM pool p JOIN pool_history_entry phe ON p.creation_utxo = phe.pool + JOIN ( + SELECT pool, MAX(sequence) AS max_sequence + FROM pool_history_entry + GROUP BY pool + ) max_phe ON phe.pool = max_phe.pool AND phe.sequence = max_phe.max_sequence WHERE p.withdrawn_in_utxo IS NULL {filters} @@ -215,6 +222,7 @@ fn db_list_active_pools( let txid = row.get(3)?; let tx_pos = row.get(4)?; let token_id = row.get(5)?; + let pool_id = row.get(6)?; let pkh = hex::decode(&owner_pkh).context("failed to decode ownerpkh")?; let owner_p2pkh_addr = cashaddr::encode( @@ -232,6 +240,7 @@ fn db_list_active_pools( tokens, txid, tx_pos, + pool_id, }) } Ok(pools)