To enable a model of Block.forgedBy
-> StakePool
and StakePool.blocksForged
-> [Block]
See https://github.com/input-output-hk/cardano-ledger-specs/pull/1637
Doesn't this duplicate the slot_leader table?
Yea, you can get to pool id through the slot_leaders table. It would, however, be very convenient if we could have the pool id in the slot leader table rather than part of the vkey. I currently convert the vkey to a pool id as follows and store it in a new column in the slot leader table:
vkey = "5820"+p['hash'][2:]
h = hashlib.blake2b(digest_size=28)
h.update(binascii.unhexlify(p['hash'][2:]))
poolid = h.hexdigest()
This allows me to do a join and build out blocks per pool fairly easily.
@disassembler Yes, it would. I've updated the title to extend the leaders table with a key for joining easily
@papacarp thanks for adding your workaround. Hopefully you can refactor away from this, as modifying schema of the tables managed by cardano-db-sync
is advised against by @erikd
Most helpful comment
Yea, you can get to pool id through the slot_leaders table. It would, however, be very convenient if we could have the pool id in the slot leader table rather than part of the vkey. I currently convert the vkey to a pool id as follows and store it in a new column in the slot leader table:
This allows me to do a join and build out blocks per pool fairly easily.