-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reserve/treasury withdrawals and pool_registrations/deregistrations
- Loading branch information
Showing
12 changed files
with
703 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
CREATE OR REPLACE FUNCTION grest.reserve_withdrawals() | ||
RETURNS TABLE ( | ||
epoch_no word31type, | ||
epoch_slot word31type, | ||
tx_hash text, | ||
block_hash text, | ||
block_height word31type, | ||
amount text, | ||
stake_address text | ||
) | ||
LANGUAGE SQL STABLE | ||
AS $$ | ||
SELECT | ||
b.epoch_no, | ||
b.epoch_slot_no, | ||
ENCODE(tx.hash,'hex'), | ||
ENCODE(b.hash,'hex'), | ||
b.block_no, | ||
r.amount::text, | ||
sa.view | ||
FROM reserve AS r | ||
LEFT JOIN tx ON r.tx_id = tx.id | ||
INNER JOIN block AS b ON tx.block_id = b.id | ||
LEFT JOIN stake_address AS sa ON sa.id = r.addr_id; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.reserve_withdrawals IS 'A list of withdrawals made from reserves (MIRs)'; --noqa: LT01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
CREATE OR REPLACE FUNCTION grest.treasury_withdrawals() | ||
RETURNS TABLE ( | ||
epoch_no word31type, | ||
epoch_slot word31type, | ||
tx_hash text, | ||
block_hash text, | ||
block_height word31type, | ||
amount text, | ||
stake_address text | ||
) | ||
LANGUAGE SQL STABLE | ||
AS $$ | ||
SELECT | ||
b.epoch_no, | ||
b.epoch_slot_no, | ||
ENCODE(tx.hash,'hex'), | ||
ENCODE(b.hash,'hex'), | ||
b.block_no, | ||
t.amount::text, | ||
sa.view | ||
FROM treasury AS t | ||
LEFT JOIN tx ON t.tx_id = tx.id | ||
INNER JOIN block AS b ON tx.block_id = b.id | ||
LEFT JOIN stake_address AS sa ON sa.id = t.addr_id; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.treasury_withdrawals IS 'A list of withdrawals made from treasury'; --noqa: LT01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CREATE OR REPLACE FUNCTION grest.pool_registrations(_epoch_no numeric) | ||
RETURNS TABLE ( | ||
pool_id_bech32 text, | ||
tx_hash text, | ||
block_hash text, | ||
block_height word31type, | ||
epoch_no word31type, | ||
epoch_slot word31type, | ||
active_epoch_no word31type | ||
) | ||
LANGUAGE SQL STABLE | ||
AS $$ | ||
SELECT | ||
ph.view, | ||
ENCODE(tx.hash,'hex'), | ||
ENCODE(b.hash,'hex'), | ||
b.block_no, | ||
b.epoch_no, | ||
b.epoch_slot_no, | ||
pu.active_epoch_no | ||
FROM pool_update AS pu | ||
LEFT JOIN tx ON pu.registered_tx_id = tx.id | ||
INNER JOIN block AS b ON tx.block_id = b.id | ||
LEFT JOIN pool_hash AS ph ON ph.id = pu.hash_id | ||
WHERE b.epoch_no = _epoch_no; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.pool_registrations IS 'A list of all pool registrations initiated in the requested epoch'; --noqa: LT01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CREATE OR REPLACE FUNCTION grest.pool_retirements(_epoch_no numeric) | ||
RETURNS TABLE ( | ||
pool_id_bech32 text, | ||
tx_hash text, | ||
block_hash text, | ||
block_height word31type, | ||
epoch_no word31type, | ||
epoch_slot word31type, | ||
active_epoch_no word31type | ||
) | ||
LANGUAGE SQL STABLE | ||
AS $$ | ||
SELECT | ||
ph.view, | ||
ENCODE(tx.hash,'hex'), | ||
ENCODE(b.hash,'hex'), | ||
b.block_no, | ||
b.epoch_no, | ||
b.epoch_slot_no, | ||
pr.retiring_epoch | ||
FROM pool_retire AS pr | ||
LEFT JOIN tx ON pr.announced_tx_id = tx.id | ||
INNER JOIN block AS b ON tx.block_id = b.id | ||
LEFT JOIN pool_hash AS ph ON ph.id = pr.hash_id | ||
WHERE b.epoch_no = _epoch_no; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.pool_registrations IS 'A list of all pool retirements initiated in the requested epoch'; --noqa: LT01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.