Skip to content

Commit

Permalink
db-sync: Refactor Shelley+ related types
Browse files Browse the repository at this point in the history
  • Loading branch information
erikd committed Nov 22, 2020
1 parent d369e69 commit ff8261c
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 53 deletions.
1 change: 1 addition & 0 deletions cardano-db-sync/cardano-db-sync.cabal
Expand Up @@ -61,6 +61,7 @@ library
Cardano.DbSync.Era.Shelley.Insert
Cardano.DbSync.Era.Shelley.Query
Cardano.DbSync.Era.Shelley.Metadata
Cardano.DbSync.Era.Shelley.Types
Cardano.DbSync.LedgerState
Cardano.DbSync.StateQuery

Expand Down
2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs
Expand Up @@ -24,9 +24,9 @@ import Control.Monad.Trans.Except.Extra (newExceptT, runExceptT)
import Control.Monad.Trans.Reader (ReaderT)

import qualified Cardano.Db as DB
import Cardano.DbSync.Era.Shelley.Types
import qualified Cardano.DbSync.Era.Shelley.Util as Shelley
import Cardano.DbSync.Error
import Cardano.DbSync.Types
import Cardano.DbSync.Util

import qualified Data.Map.Strict as Map
Expand Down
1 change: 1 addition & 0 deletions cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs
Expand Up @@ -35,6 +35,7 @@ import qualified Cardano.Db as DB
import Cardano.DbSync.Config.Types
import Cardano.DbSync.Era.Shelley.Metadata
import Cardano.DbSync.Era.Shelley.Query
import Cardano.DbSync.Era.Shelley.Types
import qualified Cardano.DbSync.Era.Shelley.Util as Shelley
import Cardano.DbSync.Error
import Cardano.DbSync.LedgerState
Expand Down
2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Query.hs
Expand Up @@ -14,8 +14,8 @@ module Cardano.DbSync.Era.Shelley.Query

import qualified Cardano.Crypto.Hash as Crypto
import Cardano.Db
import Cardano.DbSync.Era.Shelley.Types
import Cardano.DbSync.Era.Shelley.Util (unKeyHashRaw)
import Cardano.DbSync.Types
import Cardano.DbSync.Util

import Cardano.Slotting.Slot (SlotNo (..))
Expand Down
58 changes: 58 additions & 0 deletions cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Types.hs
@@ -0,0 +1,58 @@
{-# LANGUAGE DataKinds #-}
module Cardano.DbSync.Era.Shelley.Types
( CardanoBlock
, CardanoProtocol
, ShelleyAddress
, ShelleyBlock
, ShelleyDCert
, ShelleyDelegCert
, ShelleyHash
, ShelleyMIRCert
, ShelleyPoolCert
, ShelleyPoolParams
, ShelleyRewardAccount
, ShelleyStakeCreds
, ShelleyStakePoolKeyHash
, ShelleyStakingCred
, ShelleyStakingKeyHash
, ShelleyTx
, ShelleyTxBody
, ShelleyTxId
, ShelleyTxIn
, ShelleyTxOut
, ShelleyTxSeq
) where

import Cardano.DbSync.Config.Types (CardanoBlock, CardanoProtocol)

import qualified Ouroboros.Consensus.Shelley.Ledger.Block as Shelley
import Ouroboros.Consensus.Shelley.Protocol (StandardShelley)

import qualified Shelley.Spec.Ledger.Address as Shelley
import qualified Shelley.Spec.Ledger.BlockChain as Shelley
import qualified Shelley.Spec.Ledger.Credential as Shelley
import qualified Shelley.Spec.Ledger.Keys as Shelley
import qualified Shelley.Spec.Ledger.Tx as Shelley
import qualified Shelley.Spec.Ledger.TxBody as Shelley


type ShelleyAddress = Shelley.Addr StandardShelley
type ShelleyBlock = Shelley.ShelleyBlock StandardShelley
type ShelleyDCert = Shelley.DCert StandardShelley
type ShelleyDelegCert = Shelley.DelegCert StandardShelley
type ShelleyHash = Shelley.ShelleyHash StandardShelley
type ShelleyMIRCert = Shelley.MIRCert StandardShelley
type ShelleyPoolCert = Shelley.PoolCert StandardShelley
type ShelleyPoolParams = Shelley.PoolParams StandardShelley
type ShelleyRewardAccount = Shelley.RewardAcnt StandardShelley
type ShelleyStakeCreds = Shelley.StakeCreds StandardShelley
type ShelleyStakingCred = Shelley.StakeCredential StandardShelley
type ShelleyStakingKeyHash = Shelley.KeyHash 'Shelley.Staking StandardShelley
type ShelleyStakePoolKeyHash = Shelley.KeyHash 'Shelley.StakePool StandardShelley
type ShelleyTx = Shelley.Tx StandardShelley
type ShelleyTxBody = Shelley.TxBody StandardShelley
type ShelleyTxId = Shelley.TxId StandardShelley
type ShelleyTxIn = Shelley.TxIn StandardShelley
type ShelleyTxOut = Shelley.TxOut StandardShelley
type ShelleyTxSeq = Shelley.TxSeq StandardShelley

2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Util.hs
Expand Up @@ -56,7 +56,7 @@ import qualified Cardano.Crypto.KES.Class as KES
import Cardano.Db (DbLovelace (..))
import qualified Cardano.Db as Db
import Cardano.DbSync.Config
import Cardano.DbSync.Types
import Cardano.DbSync.Era.Shelley.Types

import Cardano.Slotting.Slot (SlotNo (..))

Expand Down
50 changes: 0 additions & 50 deletions cardano-db-sync/src/Cardano/DbSync/Types.hs
Expand Up @@ -4,25 +4,6 @@ module Cardano.DbSync.Types
, CardanoBlock
, CardanoProtocol
, EpochSlot (..)
, ShelleyAddress
, ShelleyBlock
, ShelleyDCert
, ShelleyDelegCert
, ShelleyHash
, ShelleyMIRCert
, ShelleyPoolCert
, ShelleyPoolParams
, ShelleyRewardAccount
, ShelleyStakeCreds
, ShelleyStakePoolKeyHash
, ShelleyStakingCred
, ShelleyStakingKeyHash
, ShelleyTx
, ShelleyTxBody
, ShelleyTxId
, ShelleyTxIn
, ShelleyTxOut
, ShelleyTxSeq
, SlotDetails (..)
, SyncState (..)
) where
Expand All @@ -34,17 +15,6 @@ import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..))
import Data.Time.Clock (UTCTime)
import Data.Word (Word64)

import qualified Ouroboros.Consensus.Shelley.Ledger.Block as Shelley
import Ouroboros.Consensus.Shelley.Protocol (StandardShelley)

import qualified Shelley.Spec.Ledger.Address as Shelley
import qualified Shelley.Spec.Ledger.BlockChain as Shelley
import qualified Shelley.Spec.Ledger.Credential as Shelley
import qualified Shelley.Spec.Ledger.Keys as Shelley
import qualified Shelley.Spec.Ledger.Tx as Shelley
import qualified Shelley.Spec.Ledger.TxBody as Shelley


data BlockDetails = BlockDetails
{ bdBlock :: !CardanoBlock
, bdSlot :: !SlotDetails
Expand All @@ -54,26 +24,6 @@ newtype EpochSlot = EpochSlot
{ unEpochSlot :: Word64
} deriving (Eq, Show)

type ShelleyAddress = Shelley.Addr StandardShelley
type ShelleyBlock = Shelley.ShelleyBlock StandardShelley
type ShelleyDCert = Shelley.DCert StandardShelley
type ShelleyDelegCert = Shelley.DelegCert StandardShelley
type ShelleyHash = Shelley.ShelleyHash StandardShelley
type ShelleyMIRCert = Shelley.MIRCert StandardShelley
type ShelleyPoolCert = Shelley.PoolCert StandardShelley
type ShelleyPoolParams = Shelley.PoolParams StandardShelley
type ShelleyRewardAccount = Shelley.RewardAcnt StandardShelley
type ShelleyStakeCreds = Shelley.StakeCreds StandardShelley
type ShelleyStakingCred = Shelley.StakeCredential StandardShelley
type ShelleyStakingKeyHash = Shelley.KeyHash 'Shelley.Staking StandardShelley
type ShelleyStakePoolKeyHash = Shelley.KeyHash 'Shelley.StakePool StandardShelley
type ShelleyTx = Shelley.Tx StandardShelley
type ShelleyTxBody = Shelley.TxBody StandardShelley
type ShelleyTxId = Shelley.TxId StandardShelley
type ShelleyTxIn = Shelley.TxIn StandardShelley
type ShelleyTxOut = Shelley.TxOut StandardShelley
type ShelleyTxSeq = Shelley.TxSeq StandardShelley

data SlotDetails = SlotDetails
{ sdSlotTime :: !UTCTime
, sdCurrentTime :: !UTCTime
Expand Down

0 comments on commit ff8261c

Please sign in to comment.