Skip to content

Commit

Permalink
Add additional metrics for block and time to tx_cbor
Browse files Browse the repository at this point in the history
  • Loading branch information
Scitz0 committed Nov 2, 2024
1 parent 4b9eabd commit f79bbc9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
15 changes: 13 additions & 2 deletions files/grest/rpc/transactions/tx_cbor.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
CREATE OR REPLACE FUNCTION grest.tx_cbor(_tx_hashes text [])
RETURNS TABLE (
tx_hash text,
block_hash text,
block_height word31type,
epoch_no word31type,
absolute_slot word63type,
tx_timestamp integer,
cbor text
)
LANGUAGE sql STABLE
AS $$
SELECT
ENCODE(tx.hash::bytea, 'hex') AS tx_hash,
ENCODE(tx_cbor.bytes::bytea, 'hex') AS tx_cbor
ENCODE(tx.hash::bytea, 'hex'),
ENCODE(block.hash, 'hex'),
block.block_no,
block.epoch_no,
block.slot_no,
EXTRACT(EPOCH FROM block.time)::integer,
ENCODE(tx_cbor.bytes::bytea, 'hex')
FROM public.tx
INNER JOIN block ON block.id = tx.block_id
LEFT JOIN public.tx_cbor ON tx.id = tx_cbor.tx_id
WHERE tx.hash::bytea = ANY(
SELECT
Expand Down
10 changes: 10 additions & 0 deletions specs/results/koiosapi-guild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4777,6 +4777,16 @@ components:
properties:
tx_hash:
$ref: "#/components/schemas/tx_info/items/properties/tx_hash"
block_hash:
$ref: "#/components/schemas/blocks/items/properties/hash"
block_height:
$ref: "#/components/schemas/blocks/items/properties/block_height"
epoch_no:
$ref: "#/components/schemas/blocks/items/properties/epoch_no"
absolute_slot:
$ref: "#/components/schemas/blocks/items/properties/abs_slot"
tx_timestamp:
$ref: "#/components/schemas/tx_info/items/properties/tx_timestamp"
cbor:
type: string
description: CBOR encoded raw transaction.
Expand Down
10 changes: 10 additions & 0 deletions specs/results/koiosapi-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4777,6 +4777,16 @@ components:
properties:
tx_hash:
$ref: "#/components/schemas/tx_info/items/properties/tx_hash"
block_hash:
$ref: "#/components/schemas/blocks/items/properties/hash"
block_height:
$ref: "#/components/schemas/blocks/items/properties/block_height"
epoch_no:
$ref: "#/components/schemas/blocks/items/properties/epoch_no"
absolute_slot:
$ref: "#/components/schemas/blocks/items/properties/abs_slot"
tx_timestamp:
$ref: "#/components/schemas/tx_info/items/properties/tx_timestamp"
cbor:
type: string
description: CBOR encoded raw transaction.
Expand Down
10 changes: 10 additions & 0 deletions specs/results/koiosapi-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4777,6 +4777,16 @@ components:
properties:
tx_hash:
$ref: "#/components/schemas/tx_info/items/properties/tx_hash"
block_hash:
$ref: "#/components/schemas/blocks/items/properties/hash"
block_height:
$ref: "#/components/schemas/blocks/items/properties/block_height"
epoch_no:
$ref: "#/components/schemas/blocks/items/properties/epoch_no"
absolute_slot:
$ref: "#/components/schemas/blocks/items/properties/abs_slot"
tx_timestamp:
$ref: "#/components/schemas/tx_info/items/properties/tx_timestamp"
cbor:
type: string
description: CBOR encoded raw transaction.
Expand Down
10 changes: 10 additions & 0 deletions specs/results/koiosapi-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4777,6 +4777,16 @@ components:
properties:
tx_hash:
$ref: "#/components/schemas/tx_info/items/properties/tx_hash"
block_hash:
$ref: "#/components/schemas/blocks/items/properties/hash"
block_height:
$ref: "#/components/schemas/blocks/items/properties/block_height"
epoch_no:
$ref: "#/components/schemas/blocks/items/properties/epoch_no"
absolute_slot:
$ref: "#/components/schemas/blocks/items/properties/abs_slot"
tx_timestamp:
$ref: "#/components/schemas/tx_info/items/properties/tx_timestamp"
cbor:
type: string
description: CBOR encoded raw transaction.
Expand Down
10 changes: 10 additions & 0 deletions specs/templates/4-api-schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,16 @@ schemas:
properties:
tx_hash:
$ref: "#/components/schemas/tx_info/items/properties/tx_hash"
block_hash:
$ref: "#/components/schemas/blocks/items/properties/hash"
block_height:
$ref: "#/components/schemas/blocks/items/properties/block_height"
epoch_no:
$ref: "#/components/schemas/blocks/items/properties/epoch_no"
absolute_slot:
$ref: "#/components/schemas/blocks/items/properties/abs_slot"
tx_timestamp:
$ref: "#/components/schemas/tx_info/items/properties/tx_timestamp"
cbor:
type: string
description: CBOR encoded raw transaction.
Expand Down

0 comments on commit f79bbc9

Please sign in to comment.