@@ -546,6 +546,69 @@ select redeemer.tx_id as tx_id, redeemer.unit_mem, redeemer.unit_steps, redeemer
546
546
asset1mu7h997yyvzrppdwjzhpex6u7khrucspxvjjuw | \x69b30e43bc5401bb34d0b12bd06cd9b537f33065aa49df7e8652739d | \x4c51 | 2 | 1 | 21000000000000 | 2021 - 02 - 03 20 :22 :23
547
547
548
548
```
549
+
550
+ ### Get blocks with 0 transactions and the pools that forged it
551
+ ``` sql
552
+ select distinct on (block .hash ) block .hash as block_hash , epoch_no, tx_count, pool_hash .hash_raw as pool_hash,
553
+ pool_update .pledge , pool_update .active_epoch_no , pool_metadata_ref .url , pool_offline_data .ticker_name
554
+ from block join slot_leader on block .slot_leader_id = slot_leader .id
555
+ join pool_hash on slot_leader .pool_hash_id = pool_hash .id
556
+ join pool_update on pool_update .hash_id = pool_hash .id
557
+ left join pool_metadata_ref on pool_update .meta_id = pool_metadata_ref .id
558
+ left join pool_offline_data on pool_offline_data .pmr_id = pool_metadata_ref .id
559
+ where tx_count = 0 and epoch_no > 150
560
+ order by block .hash , pool_update .active_epoch_no desc ;
561
+
562
+
563
+ block_hash | epoch_no | tx_count | pool_hash | pledge | active_epoch_no | url | ticker_name
564
+ -- ------------------------------------------------------------------+----------+----------+------------------------------------------------------------+-----------------+-----------------+------------------------------------------------------------------+-------------
565
+ \x0000f4b44d1484d7280f087c1df94f068a02e23570e8ed9eb5c0dd980d4c46c1 | 165 | 0 | \xe402f5894b8a7073f198bb0710d6294f2ac354ede2577b5ce15159a4 | 50000000000 | 137 | https:// www .canadastakes .ca/ metadata/ can1- testnet- metadata .json |
566
+ \x0001715520d185accd550c7b6c0811a2589e778e6408ffcd75b0f83f4f45c2c0 | 153 | 0 | \xacfd479740bde8289885694e69e3494f7dcbcfdca540aead48c5d653 | 64000000000000 | 100 | |
567
+ \x00044646beb7d24dce8cd74408c76b9816453a451fc030c42cc9961be55932d9 | 163 | 0 | \x1e2191487bed3de4bf440d5ff80bdae31d7f22798d3a93444302acb3 | 64000000000000 | 100 | |
568
+ \x000732a2f62e289930c2779559a975566395dcf0cf32130f3852a6e031d13d61 | 154 | 0 | \xd9dc497e633c2f1c665467e1ed7a93e4f8541bfbabe1cc31818fb20f | 1000000000000 | 131 | https:// www .uniquestaking .com/ pool/ uniq9/ 1ecf39ad- 4f3c- 4043 |
569
+ ```
549
570
---
550
571
572
+ ### Query all delegators and some basic info
573
+ ``` sql
574
+ SELECT sa .view AS address,
575
+ nh .view AS delegated_now_poolid,
576
+ d .active_epoch_no delegated_now_epoch,
577
+ oh .view AS delegated_before_poolid,
578
+ od .active_epoch_no AS delegated_before_epoch,
579
+ d .addr_id ,
580
+ br." time" AS stake_key_registered
581
+ FROM ( SELECT max (delegation .id ) AS id
582
+ FROM delegation
583
+ GROUP BY delegation .addr_id ) a
584
+ LEFT JOIN delegation d ON d .id = a .id
585
+ LEFT JOIN tx txn ON txn .id = d .tx_id
586
+ LEFT JOIN block bn ON bn .id = txn .block_id
587
+ LEFT JOIN stake_address sa ON sa .id = d .addr_id
588
+ LEFT JOIN stake_deregistration de ON de .addr_id = d .addr_id AND de .id = (( SELECT max (stake_deregistration .id ) AS max
589
+ FROM stake_deregistration
590
+ WHERE stake_deregistration .addr_id = d .addr_id ))
591
+ LEFT JOIN stake_registration re ON re .addr_id = d .addr_id AND re .id = (( SELECT max (stake_registration .id ) AS max
592
+ FROM stake_registration
593
+ WHERE stake_registration .addr_id = d .addr_id ))
594
+ LEFT JOIN delegation od ON od .addr_id = d .addr_id AND od .id = (( SELECT max (delegation .id ) AS max
595
+ FROM delegation
596
+ WHERE delegation .addr_id = d .addr_id AND NOT delegation .pool_hash_id = d .pool_hash_id ))
597
+ LEFT JOIN tx txo ON txo .id = od .tx_id
598
+ LEFT JOIN block bo ON bo .id = txo .block_id
599
+ LEFT JOIN pool_hash nh ON nh .id = d .pool_hash_id
600
+ LEFT JOIN pool_hash oh ON oh .id = od .pool_hash_id
601
+ LEFT JOIN tx txr ON txr .id = re .tx_id
602
+ LEFT JOIN block br ON br .id = txr .block_id
603
+ WHERE (de .tx_id < re .tx_id OR de.* IS NULL );
604
+
605
+
606
+ address | delegated_now_poolid | delegated_now_epoch | delegated_before_poolid | delegated_before_epoch | addr_id | stake_key_registered
607
+ -- -----------------------------------------------------------+----------------------------------------------------------+---------------------+----------------------------------------------------------+------------------------+---------+----------------------
608
+ stake1u9ylzsgxaa6xctf4juup682ar3juj85n8tx3hthnljg47zctvm3rc | pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy | 210 | | | 1 | 2020 - 07 - 29 22 :41 :31
609
+ stake1u8mt5gqclkq0swmvzx9lvq4jgwsnx9yh030yrxwqwllu0mq2m0l4n | pool1qqqqzyqf8mlm70883zht60n4q6uqxg4a8x266sewv8ad2grkztl | 317 | pool1qqqz9vlskay2gv3ec5pyck8c2tq9ty7dpfm60x8shvapguhcemt | 211 | 3 | 2020 - 08 - 06 20 :00 :11
610
+ ```
611
+ ---
612
+
613
+
551
614
[ Query.hs ] : https://github.com/input-output-hk/cardano-db-sync/blob/master/cardano-db/src/Cardano/Db/Query.hs
0 commit comments