Skip to content

Commit

Permalink
Sqlite: Remove copy&paste code
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Nov 19, 2019
1 parent 0bd93e6 commit 98c89bb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 164 deletions.
1 change: 0 additions & 1 deletion lib/core/cardano-wallet-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ library
Cardano.Pool.DB.Model
Cardano.Pool.DB.Sqlite
Cardano.Pool.DB.Sqlite.TH
Cardano.Pool.DB.Sqlite.Types
Cardano.Pool.Metrics
Cardano.Wallet
Cardano.Wallet.Api
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Pool/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import Cardano.DB.Sqlite
)
import Cardano.Pool.DB
( DBLayer (..), ErrPointAlreadyExists (..) )
import Cardano.Pool.DB.Sqlite.Types
import Cardano.Wallet.DB.Sqlite.Types
( BlockId (..) )
import Cardano.Wallet.Primitive.Types
( BlockHeader (..), EpochNo (..), PoolId, SlotId (..) )
Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Pool/DB/Sqlite/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Cardano.Pool.DB.Sqlite.TH where

import Prelude

import Cardano.Pool.DB.Sqlite.Types
import Cardano.Wallet.DB.Sqlite.Types
( sqlSettings' )
import Data.Word
( Word32, Word64 )
Expand All @@ -31,7 +31,7 @@ import Database.Persist.TH
import GHC.Generics
( Generic (..) )

import qualified Cardano.Pool.DB.Sqlite.Types as W
import qualified Cardano.Wallet.DB.Sqlite.Types as W
import qualified Cardano.Wallet.Primitive.Types as W

share
Expand Down
158 changes: 0 additions & 158 deletions lib/core/src/Cardano/Pool/DB/Sqlite/Types.hs

This file was deleted.

19 changes: 17 additions & 2 deletions lib/core/src/Cardano/Wallet/DB/Sqlite/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,15 @@ instance PersistFieldSql SlotId where
artificialEpochLength :: EpochLength
artificialEpochLength = EpochLength maxBound

persistSlotId :: SlotId -> PersistValue
persistSlotId = toPersistValue . flatSlot artificialEpochLength

unPersistSlotId :: PersistValue -> Either Text SlotId
unPersistSlotId = fmap (fromFlatSlot artificialEpochLength) . fromPersistValue

instance PersistField SlotId where
toPersistValue = toPersistValue . flatSlot artificialEpochLength
fromPersistValue = fmap (fromFlatSlot artificialEpochLength) . fromPersistValue
toPersistValue = persistSlotId
fromPersistValue = unPersistSlotId

instance ToJSON SlotId where
toJSON = genericToJSON defaultOptions
Expand All @@ -284,6 +290,15 @@ instance ToJSON EpochNo where
instance FromJSON EpochNo where
parseJSON = fmap EpochNo . parseJSON

instance ToHttpApiData SlotId where
toUrlPiece = error "toUrlPiece stub needed for persistent"
instance FromHttpApiData SlotId where
parseUrlPiece = error "parseUrlPiece stub needed for persistent"
instance PathPiece SlotId where
toPathPiece = error "toPathPiece stub needed for persistent"
fromPathPiece = error "fromPathPiece stub needed for persistent"


----------------------------------------------------------------------------
-- SyncProgress

Expand Down

0 comments on commit 98c89bb

Please sign in to comment.