Skip to content

Commit

Permalink
Add slot_internal_index field to PoolOwner table.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Jul 9, 2020
1 parent 0e74cca commit 7bf5407
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
15 changes: 12 additions & 3 deletions lib/core/src/Cardano/Pool/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ newDBLayer trace fp = do
(snd <$> poolMetadata cert)
_ <- repsert poolRegistrationKey poolRegistrationRow
insertMany_ $
zipWith (PoolOwner poolId slotId) (poolOwners cert) [0..]
zipWith
(PoolOwner poolId slotId slotInternalIndex)
(poolOwners cert)
[0..]

, readPoolRegistration = \poolId -> do
let filterBy = [ PoolRegistrationPoolId ==. poolId ]
Expand Down Expand Up @@ -247,8 +250,14 @@ newDBLayer trace fp = do
(,) <$> poolMetadataUrl <*> poolMetadataHash
poolOwners <- fmap (poolOwnerOwner . entityVal) <$>
selectList
[ PoolOwnerPoolId ==. poolId ]
[ Desc PoolOwnerSlot, Asc PoolOwnerIndex ]
[ PoolOwnerPoolId
==. poolId
, PoolOwnerSlot
==. slotId
, PoolOwnerSlotInternalIndex
==. slotInternalIndex
]
[ Asc PoolOwnerIndex ]
let cert = PoolRegistrationCertificate
{ poolId
, poolOwners
Expand Down
11 changes: 6 additions & 5 deletions lib/core/src/Cardano/Pool/DB/Sqlite/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ StakeDistribution sql=stake_distribution

-- Mapping from pool id to owner.
PoolOwner sql=pool_owner
poolOwnerPoolId W.PoolId sql=pool_id
poolOwnerSlot W.SlotId sql=slot
poolOwnerOwner W.PoolOwner sql=pool_owner
poolOwnerIndex Word8 sql=pool_owner_index
poolOwnerPoolId W.PoolId sql=pool_id
poolOwnerSlot W.SlotId sql=slot
poolOwnerSlotInternalIndex W.SlotInternalIndex sql=slot_internal_index
poolOwnerOwner W.PoolOwner sql=pool_owner
poolOwnerIndex Word8 sql=pool_owner_index

Primary poolOwnerPoolId poolOwnerSlot poolOwnerOwner poolOwnerIndex
Primary poolOwnerPoolId poolOwnerSlot poolOwnerSlotInternalIndex poolOwnerOwner poolOwnerIndex
deriving Show Generic

-- Mapping of registration certificate to pool
Expand Down

0 comments on commit 7bf5407

Please sign in to comment.