Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
block_info RPC, minor changes to blocks RPC (#1086)
* Add block_info RPC * Styling changes on blocks rpc * Add block_info docs * revert time column name change
- Loading branch information
1 parent
dfa72c2
commit a3f0e91
Showing
3 changed files
with
109 additions
and
22 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
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,56 @@ | ||
DROP FUNCTION IF EXISTS grest.block_info (_block_hash text); | ||
|
||
CREATE FUNCTION grest.block_info (_block_hash text) | ||
RETURNS TABLE ( | ||
HASH text, | ||
EPOCH uinteger, | ||
ABS_SLOT uinteger, | ||
EPOCH_SLOT uinteger, | ||
HEIGHT uinteger, | ||
BLOCK_TIME timestamp, | ||
TX_COUNT bigint, | ||
VRF_KEY varchar, | ||
OP_CERT_COUNTER word63type, | ||
POOL varchar, | ||
PARENT_HASH text, | ||
CHILD_HASH text) | ||
LANGUAGE PLPGSQL | ||
AS $$ | ||
BEGIN | ||
RETURN QUERY | ||
SELECT | ||
_block_hash AS HASH, | ||
b.EPOCH_NO AS EPOCH, | ||
b.SLOT_NO AS ABS_SLOT, | ||
b.EPOCH_SLOT_NO AS EPOCH_SLOT, | ||
b.BLOCK_NO AS HEIGHT, | ||
b.TIME AS BLOCK_TIME, | ||
b.TX_COUNT, | ||
b.VRF_KEY, | ||
b.OP_CERT_COUNTER, | ||
ph.VIEW AS POOL, | ||
( | ||
SELECT | ||
ENCODE(tB.HASH::bytea, 'hex') | ||
FROM | ||
block tB | ||
WHERE | ||
id = b.id - 1) AS PARENT_HASH, | ||
( | ||
SELECT | ||
ENCODE(tB.HASH::bytea, 'hex') | ||
FROM | ||
block tB | ||
WHERE | ||
id = b.id + 1) AS CHILD_HASH | ||
FROM | ||
BLOCK B | ||
LEFT JOIN SLOT_LEADER SL ON SL.ID = B.SLOT_LEADER_ID | ||
LEFT JOIN POOL_HASH PH ON PH.ID = SL.POOL_HASH_ID | ||
WHERE | ||
ENCODE(B.HASH::bytea, 'hex') = _block_hash; | ||
END; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.block_info IS 'Get detailed information about a specific block'; | ||
|
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