Skip to content

Commit f262780

Browse files
committed
Rename new_committee_info and new_committee_member
to simply committee and committee_member
1 parent c08cb3d commit f262780

File tree

5 files changed

+56
-42
lines changed

5 files changed

+56
-42
lines changed

cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module Cardano.DbSync.Era.Universal.Insert.GovAction (
2828
)
2929
where
3030

31-
import Cardano.BM.Trace (Trace, logWarning)
31+
import Cardano.BM.Trace (Trace, logInfo, logWarning)
3232
import qualified Cardano.Crypto as Crypto
3333
import Cardano.Db (DbWord64 (..))
3434
import qualified Cardano.Db as DB
@@ -140,33 +140,33 @@ insertGovActionProposal cache blkId txId govExpiresAt mmCommittee (index, pp) =
140140
insertNewCommittee gapId removed added q = do
141141
void $ insertCommittee' gapId (updatedCommittee removed added q <$> mmCommittee) q
142142

143-
insertCommittee :: (MonadIO m, MonadBaseControl IO m) => Maybe DB.GovActionProposalId -> Committee StandardConway -> ReaderT SqlBackend m DB.NewCommitteeInfoId
143+
insertCommittee :: (MonadIO m, MonadBaseControl IO m) => Maybe DB.GovActionProposalId -> Committee StandardConway -> ReaderT SqlBackend m DB.CommitteeId
144144
insertCommittee mgapId committee = do
145145
insertCommittee' mgapId (Just committee) (committeeThreshold committee)
146146

147-
insertCommittee' :: (MonadIO m, MonadBaseControl IO m) => Maybe DB.GovActionProposalId -> Maybe (Committee StandardConway) -> UnitInterval -> ReaderT SqlBackend m DB.NewCommitteeInfoId
147+
insertCommittee' :: (MonadIO m, MonadBaseControl IO m) => Maybe DB.GovActionProposalId -> Maybe (Committee StandardConway) -> UnitInterval -> ReaderT SqlBackend m DB.CommitteeId
148148
insertCommittee' mgapId mcommittee q = do
149-
infoId <- insertNewCommitteeInfo
149+
committeeId <- insertCommitteeDB
150150
whenJust mcommittee $ \committee ->
151-
mapM_ (insertNewMember infoId) (Map.toList $ committeeMembers committee)
152-
pure infoId
151+
mapM_ (insertNewMember committeeId) (Map.toList $ committeeMembers committee)
152+
pure committeeId
153153
where
154154
r = unboundRational q -- TODO work directly with Ratio Word64. This is not currently supported in ledger
155-
insertNewMember infoId (cred, e) = do
155+
insertNewMember committeeId (cred, e) = do
156156
chId <- insertCommitteeHash cred
157-
void . DB.insertNewCommitteeMember $
158-
DB.NewCommitteeMember
159-
{ DB.newCommitteeMemberNewCommitteeInfoId = infoId
160-
, DB.newCommitteeMemberCommitteeHashId = chId
161-
, DB.newCommitteeMemberExpirationEpoch = unEpochNo e
157+
void . DB.insertCommitteeMember $
158+
DB.CommitteeMember
159+
{ DB.committeeMemberCommitteeId = committeeId
160+
, DB.committeeMemberCommitteeHashId = chId
161+
, DB.committeeMemberExpirationEpoch = unEpochNo e
162162
}
163163

164-
insertNewCommitteeInfo =
165-
DB.insertNewCommitteeInfo $
166-
DB.NewCommitteeInfo
167-
{ DB.newCommitteeInfoGovActionProposalId = mgapId
168-
, DB.newCommitteeInfoQuorumNumerator = fromIntegral $ numerator r
169-
, DB.newCommitteeInfoQuorumDenominator = fromIntegral $ denominator r
164+
insertCommitteeDB =
165+
DB.insertCommittee $
166+
DB.Committee
167+
{ DB.committeeGovActionProposalId = mgapId
168+
, DB.committeeQuorumNumerator = fromIntegral $ numerator r
169+
, DB.committeeQuorumDenominator = fromIntegral $ denominator r
170170
}
171171

172172
--------------------------------------------------------------------------------------
@@ -465,7 +465,7 @@ insertUpdateEnacted trce blkId epochNo enactedState = do
465465
(Nothing, Nothing) -> pure (Nothing, Nothing)
466466
(Nothing, Just committee) -> do
467467
-- No enacted proposal means we're after conway genesis territory
468-
committeeIds <- lift $ DB.queryProposalNewCommitteeInfo Nothing
468+
committeeIds <- lift $ DB.queryProposalCommittee Nothing
469469
case committeeIds of
470470
[] -> do
471471
committeeId <- lift $ insertCommittee Nothing committee
@@ -476,7 +476,7 @@ insertUpdateEnacted trce blkId epochNo enactedState = do
476476
-- No committee with enacted action means it's a no confidence action.
477477
pure (Nothing, Just committeeGaId)
478478
(Just committeeGaId, Just committee) -> do
479-
committeeIds <- lift $ DB.queryProposalNewCommitteeInfo (Just committeeGaId)
479+
committeeIds <- lift $ DB.queryProposalCommittee (Just committeeGaId)
480480
case committeeIds of
481481
[] -> do
482482
-- This should never happen. Having a committee and an enacted action, means

cardano-db/src/Cardano/Db/Delete.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ deleteTablesAfterTxId mtxId mtxInId mtxOutId mmaTxOutId = do
163163
mgaId <- queryMinRefId GovActionProposalTxId txId
164164
whenJust mgaId $ \gaId -> do
165165
queryFirstAndDeleteAfter TreasuryWithdrawalGovActionProposalId gaId
166-
queryFirstAndDeleteAfter' NewCommitteeInfoGovActionProposalId gaId
166+
queryFirstAndDeleteAfter' CommitteeGovActionProposalId gaId
167167
queryFirstAndDeleteAfter' ConstitutionGovActionProposalId gaId
168168
deleteWhere [GovActionProposalId >=. gaId]
169169
minPmr <- queryMinRefId PoolMetadataRefRegisteredTxId txId

cardano-db/src/Cardano/Db/Insert.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ module Cardano.Db.Insert (
8080
insertConstitution,
8181
insertGovActionProposal,
8282
insertTreasuryWithdrawal,
83-
insertNewCommitteeInfo,
84-
insertNewCommitteeMember,
83+
insertCommittee,
84+
insertCommitteeMember,
8585
insertVotingProcedure,
8686
insertDrepHash,
8787
insertCommitteeHash,
@@ -442,11 +442,11 @@ insertGovActionProposal = insertUnchecked "GovActionProposal"
442442
insertTreasuryWithdrawal :: (MonadBaseControl IO m, MonadIO m) => TreasuryWithdrawal -> ReaderT SqlBackend m TreasuryWithdrawalId
443443
insertTreasuryWithdrawal = insertUnchecked "TreasuryWithdrawal"
444444

445-
insertNewCommitteeInfo :: (MonadBaseControl IO m, MonadIO m) => NewCommitteeInfo -> ReaderT SqlBackend m NewCommitteeInfoId
446-
insertNewCommitteeInfo = insertUnchecked "NewCommitteeInfo"
445+
insertCommittee :: (MonadBaseControl IO m, MonadIO m) => Committee -> ReaderT SqlBackend m CommitteeId
446+
insertCommittee = insertUnchecked "Committee"
447447

448-
insertNewCommitteeMember :: (MonadBaseControl IO m, MonadIO m) => NewCommitteeMember -> ReaderT SqlBackend m NewCommitteeMemberId
449-
insertNewCommitteeMember = insertUnchecked "NewCommitteeMember"
448+
insertCommitteeMember :: (MonadBaseControl IO m, MonadIO m) => CommitteeMember -> ReaderT SqlBackend m CommitteeMemberId
449+
insertCommitteeMember = insertUnchecked "CommitteeMember"
450450

451451
insertVotingProcedure :: (MonadBaseControl IO m, MonadIO m) => VotingProcedure -> ReaderT SqlBackend m VotingProcedureId
452452
insertVotingProcedure = insertUnchecked "VotingProcedure"

cardano-db/src/Cardano/Db/Query.hs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module Cardano.Db.Query (
6363
queryDrepHashAlwaysNoConfidence,
6464
queryCommitteeHash,
6565
queryProposalConstitution,
66-
queryProposalNewCommitteeInfo,
66+
queryProposalCommittee,
6767
-- queries used in smash
6868
queryOffChainPoolData,
6969
queryPoolRegister,
@@ -839,17 +839,25 @@ queryProposalConstitution :: MonadIO m => Maybe GovActionProposalId -> ReaderT S
839839
queryProposalConstitution mgapId = do
840840
res <- select $ do
841841
c <- from $ table @Constitution
842-
where_ (c ^. ConstitutionGovActionProposalId ==. val mgapId)
842+
where_ (bl c)
843843
pure $ c ^. ConstitutionId
844844
pure $ unValue <$> res
845+
where
846+
bl c = case mgapId of
847+
Nothing -> isNothing (c ^. ConstitutionGovActionProposalId)
848+
Just vl -> c ^. ConstitutionGovActionProposalId ==. val (Just vl)
845849

846-
queryProposalNewCommitteeInfo :: MonadIO m => Maybe GovActionProposalId -> ReaderT SqlBackend m [NewCommitteeInfoId]
847-
queryProposalNewCommitteeInfo mgapId = do
850+
queryProposalCommittee :: MonadIO m => Maybe GovActionProposalId -> ReaderT SqlBackend m [CommitteeId]
851+
queryProposalCommittee mgapId = do
848852
res <- select $ do
849-
c <- from $ table @NewCommitteeInfo
850-
where_ (c ^. NewCommitteeInfoGovActionProposalId ==. val mgapId)
851-
pure $ c ^. NewCommitteeInfoId
853+
c <- from $ table @Committee
854+
where_ (bl c)
855+
pure $ c ^. CommitteeId
852856
pure $ unValue <$> res
857+
where
858+
bl c = case mgapId of
859+
Nothing -> isNothing (c ^. CommitteeGovActionProposalId)
860+
Just vl -> c ^. CommitteeGovActionProposalId ==. val (Just vl)
853861

854862
{--------------------------------------------
855863
Queries use in SMASH

cardano-db/src/Cardano/Db/Schema.hs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,13 @@ share
621621
stakeAddressId StakeAddressId noreference
622622
amount DbLovelace sqltype=lovelace
623623

624-
NewCommitteeInfo
624+
Committee
625625
govActionProposalId GovActionProposalId Maybe noreference
626626
quorumNumerator Word64
627627
quorumDenominator Word64
628628

629-
NewCommitteeMember
630-
newCommitteeInfoId NewCommitteeInfoId -- here intentionally we use foreign keys
629+
CommitteeMember
630+
committeeId CommitteeId -- here intentionally we use foreign keys
631631
committeeHashId CommitteeHashId noreference
632632
expirationEpoch Word64 sqltype=word31type
633633

@@ -655,7 +655,7 @@ share
655655
UniqueDrepDistr hashId epochNo
656656

657657
EpochState
658-
committeeId NewCommitteeInfoId Maybe noreference
658+
committeeId CommitteeId Maybe noreference
659659
noConfidenceId GovActionProposalId Maybe noreference
660660
constitutionId ConstitutionId Maybe noreference
661661
epochNo Word64 sqltype=word31type
@@ -1321,11 +1321,17 @@ schemaDocs =
13211321
TreasuryWithdrawalStakeAddressId # "The address that benefits from this withdrawal."
13221322
TreasuryWithdrawalAmount # "The amount for this withdrawl."
13231323

1324-
NewCommitteeInfo --^ do
1324+
Committee --^ do
13251325
"A table for new committee proposed on a GovActionProposal. New in 13.2-Conway."
1326-
NewCommitteeInfoGovActionProposalId # "The GovActionProposal table index for this new committee. This can be null for genesis committees."
1327-
NewCommitteeInfoQuorumNumerator # "The proposed quorum nominator."
1328-
NewCommitteeInfoQuorumDenominator # "The proposed quorum denominator."
1326+
CommitteeGovActionProposalId # "The GovActionProposal table index for this new committee. This can be null for genesis committees."
1327+
CommitteeQuorumNumerator # "The proposed quorum nominator."
1328+
CommitteeQuorumDenominator # "The proposed quorum denominator."
1329+
1330+
CommitteeMember --^ do
1331+
"A table for members of the committee. A committee can have multiple members. New in 13.3-Conway."
1332+
CommitteeMemberCommitteeId # "The reference to the committee"
1333+
CommitteeMemberCommitteeHashId # "The reference to the committee hash"
1334+
CommitteeMemberExpirationEpoch # "The epoch this member expires"
13291335

13301336
Constitution --^ do
13311337
"A table for constitutiona attached to a GovActionProposal. New in 13.2-Conway."

0 commit comments

Comments
 (0)