Skip to content

Commit 01e4393

Browse files
authored
Merge pull request #1316 from input-output-hk/refactor/LW-10561-use-deposit-fields
LW-10561 - Use new deposit fields from db-sync
2 parents c13889c + ebe7b69 commit 01e4393

File tree

1 file changed

+4
-24
lines changed
  • packages/cardano-services/src/ChainHistory/DbSyncChainHistory

1 file changed

+4
-24
lines changed

packages/cardano-services/src/ChainHistory/DbSyncChainHistory/queries.ts

+4-24
Original file line numberDiff line numberDiff line change
@@ -252,27 +252,12 @@ export const findPoolRegisterCertsByTxIds = `
252252
pool."view" AS pool_id,
253253
tx.hash AS tx_id,
254254
CASE
255-
WHEN (
256-
SELECT count(*) = 0
257-
FROM pool_update AS pu
258-
WHERE pu.registered_tx_id BETWEEN (
259-
CASE WHEN (
260-
SELECT count(*) FROM pool_retire AS pr
261-
WHERE pr.announced_tx_id < cert.registered_tx_id
262-
) > 0 THEN (
263-
SELECT max(pr.announced_tx_id) FROM pool_retire AS pr
264-
WHERE pr.announced_tx_id < cert.registered_tx_id
265-
)
266-
ELSE 0 END
267-
) AND cert.registered_tx_id - 1
268-
) THEN pool_deposit
269-
ELSE '0'
255+
WHEN cert.deposit IS NULL THEN '0'
256+
ELSE cert.deposit
270257
END AS deposit
271258
FROM tx
272259
JOIN pool_update AS cert ON cert.registered_tx_id = tx.id
273260
JOIN pool_hash AS pool ON pool.id = cert.hash_id
274-
JOIN block ON block_id = block.id
275-
JOIN epoch_param ON epoch_param.epoch_no = (CASE WHEN block.epoch_no > 1 THEN block.epoch_no ELSE 1 END)
276261
WHERE tx.id = ANY($1)
277262
ORDER BY tx.id ASC`;
278263

@@ -307,12 +292,10 @@ export const findStakeCertsByTxIds = `
307292
addr."view" AS address,
308293
TRUE AS registration,
309294
tx.hash AS tx_id,
310-
epoch_param.key_deposit AS deposit
295+
cert.deposit AS deposit
311296
FROM tx
312297
JOIN stake_registration AS cert ON cert.tx_id = tx.id
313298
JOIN stake_address AS addr ON addr.id = cert.addr_id
314-
JOIN block ON block_id = block.id
315-
JOIN epoch_param ON block.epoch_no = epoch_param.epoch_no
316299
WHERE tx.id = ANY($1)
317300
ORDER BY tx.id ASC)
318301
UNION
@@ -321,10 +304,7 @@ export const findStakeCertsByTxIds = `
321304
addr."view" AS address,
322305
FALSE AS registration,
323306
tx.hash AS tx_id,
324-
(SELECT key_deposit FROM stake_registration AS sr
325-
JOIN tx AS tx2 ON sr.tx_id = tx2.id
326-
JOIN block ON tx2.block_id = block.id
327-
JOIN epoch_param ON block.epoch_no = epoch_param.epoch_no
307+
(SELECT sr.deposit FROM stake_registration AS sr
328308
WHERE sr.addr_id = cert.addr_id
329309
AND sr.tx_id < tx.id
330310
ORDER BY sr.tx_id DESC

0 commit comments

Comments
 (0)