-
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.
## Description <!--- Describe your changes --> - Make use of asset-txo-cache for top assets on mainnet, and use this cache for `asset_addresses` and `policy_asset_addresses` - Add v0 RPC redirectors to keep serve v0 endpoints from v1 - Convert few simple RPC functions from PLPGSQL to SQL language to help with inline filtering - Address linting results from SQLFluff - Move db-scripts from guild-operators repository to koios-artifacts repository - Drop stale db-scripts/genesis_table.sql file - Add 3 additional indexes for collateral and reference inputs based on query times - Add top 3 assets for preview/preprod to asset-txo-cache - Bump schema version for koios-1.1.0
- Loading branch information
Showing
72 changed files
with
1,768 additions
and
264 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,15 @@ | ||
version = 1 | ||
|
||
test_patterns = ["tests/**"] | ||
|
||
[[analyzers]] | ||
name = "shell" | ||
|
||
[[analyzers]] | ||
name = "python" | ||
|
||
[analyzers.meta] | ||
runtime_version = "3.x.x" | ||
|
||
[[analyzers]] | ||
name = "sql" |
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
Empty file.
Empty file.
Empty file.
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,12 @@ | ||
#!/bin/bash | ||
DB_NAME=cexplorer | ||
|
||
tip=$(psql ${DB_NAME} -qbt -c "SELECT EXTRACT(epoch FROM time)::integer FROM block ORDER BY id DESC LIMIT 1;" | xargs) | ||
|
||
if [[ $(( $(date +%s) - tip )) -gt 300 ]]; then | ||
echo "$(date +%F_%H:%M:%S) Skipping as database has not received a new block in past 300 seconds!" && exit 1 | ||
fi | ||
|
||
echo "$(date +%F_%H:%M:%S) Running asset txo cache update..." | ||
psql ${DB_NAME} -qbt -c "SELECT grest.asset_txo_cache_update();" 1>/dev/null 2>&1 | ||
echo "$(date +%F_%H:%M:%S) Job done!" |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
files/grest/cron/jobs/stake-distribution-new-accounts-update.sh
100644 → 100755
Empty file.
Empty file.
Empty file.
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
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
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
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,68 @@ | ||
CREATE OR REPLACE FUNCTION grest.asset_txo_cache_update() | ||
RETURNS void | ||
LANGUAGE plpgsql | ||
AS $$ | ||
BEGIN | ||
IF ( | ||
SELECT COUNT(pid) > 1 | ||
FROM pg_stat_activity | ||
WHERE state = 'active' | ||
AND query ILIKE '%grest.asset_txo_cache_update%' | ||
AND datname = (SELECT current_database()) | ||
) THEN | ||
RAISE EXCEPTION 'Previous asset_txo_cache_update query still running but should have completed! Exiting...'; | ||
END IF; | ||
|
||
CREATE TEMP TABLE tmp_ma AS ( | ||
SELECT ma1.id | ||
FROM grest.asset_cache_control AS acc1 | ||
LEFT JOIN multi_asset AS ma1 ON ma1.policy = acc1.policy | ||
LEFT JOIN grest.asset_tx_out_cache AS atoc1 ON ma1.id = atoc1.ma_id | ||
WHERE atoc1.ma_id IS NULL | ||
); | ||
|
||
WITH | ||
ma_filtered AS | ||
( | ||
(SELECT | ||
mto.tx_out_id, | ||
mto.quantity, | ||
mto.ident | ||
FROM grest.asset_cache_control AS acc | ||
LEFT JOIN multi_asset AS ma ON ma.policy = acc.policy | ||
LEFT JOIN ma_tx_out AS mto ON mto.ident = ma.id | ||
WHERE ma.id IN | ||
(SELECT id FROM tmp_ma) | ||
) | ||
UNION ALL | ||
( | ||
SELECT | ||
mto.tx_out_id, | ||
mto.quantity, | ||
mto.ident | ||
FROM grest.asset_cache_control AS acc | ||
LEFT JOIN multi_asset AS ma ON ma.policy = acc.policy | ||
LEFT JOIN ma_tx_out AS mto ON mto.ident = ma.id | ||
WHERE mto.tx_out_id > (SELECT COALESCE(MAX(atoc.txo_id),0) FROM grest.asset_tx_out_cache AS atoc) | ||
) | ||
) | ||
INSERT INTO grest.asset_tx_out_cache | ||
SELECT | ||
mf.ident, | ||
mf.tx_out_id, | ||
mf.quantity | ||
FROM ma_filtered AS mf | ||
LEFT JOIN tx_out AS txo ON mf.tx_out_id = txo.id | ||
WHERE txo.consumed_by_tx_in_id IS NULL AND txo.id < (SELECT MAX(id) from tx_out) | ||
; | ||
|
||
DELETE FROM grest.asset_tx_out_cache WHERE txo_id IN | ||
(SELECT atoc.txo_id | ||
FROM grest.asset_tx_out_cache AS atoc | ||
LEFT JOIN tx_out AS txo ON atoc.txo_id = txo.id | ||
WHERE txo.consumed_by_tx_in_id IS NOT NULL | ||
OR txo.id IS NULL); | ||
DROP TABLE tmp_ma; | ||
|
||
END; | ||
$$; |
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
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
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
Oops, something went wrong.