bug: Fix 'active' pools showing old instance

This commit is contained in:
Dagur Valberg Johannsson 2024-11-13 10:13:58 +01:00
parent 3da5b62c24
commit 7ab3e1960b
No known key found for this signature in database
GPG key ID: FD701804AEE88107

View file

@ -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)