Skip to content

Commit 6b3241d

Browse files
committed
Avoid repeating.
1 parent 6944c3b commit 6b3241d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/BotPlutusInterface/TimeSlot.hs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ slotToPOSIXTimeIO pabConf lSlot = runEitherT $ do
7171
nodeInfo <- liftIO $ mkNodeInfo pabConf
7272
eraHistory <- newET (queryEraHistory nodeInfo)
7373
sysStart <- newET $ querySystemStart nodeInfo
74-
pparams <-
75-
liftEither
76-
. fmap (CAPI.toLedgerPParams CAPI.ShelleyBasedEraBabbage)
77-
. maybeToEither (TimeSlotConversionError "No protocol params found")
78-
$ pcProtocolParams pabConf
74+
pparams <- mkPParams pabConf
7975
let epochInfo = toLedgerEpochInfo eraHistory
8076

8177
firstEitherT toError . hoistEither $
@@ -111,11 +107,7 @@ posixTimeRangeToContainedSlotRangeIO
111107
nodeInfo <- liftIO $ mkNodeInfo pabConf
112108
sysStart <- newET $ querySystemStart nodeInfo
113109
eraHistory <- newET $ queryEraHistory nodeInfo
114-
pparams <-
115-
liftEither
116-
. fmap (CAPI.toLedgerPParams CAPI.ShelleyBasedEraBabbage)
117-
. maybeToEither (TimeSlotConversionError "No protocol params found")
118-
$ pcProtocolParams pabConf
110+
pparams <- mkPParams pabConf
119111
let epochInfo = toLedgerEpochInfo eraHistory
120112

121113
let extTimeToExtSlot = convertExtended sysStart eraHistory
@@ -224,3 +216,12 @@ mkNodeInfo :: PABConfig -> IO NodeInfo
224216
mkNodeInfo pabConf =
225217
NodeInfo (pcNetwork pabConf)
226218
<$> getEnv "CARDANO_NODE_SOCKET_PATH"
219+
220+
mkPParams ::
221+
PABConfig ->
222+
EitherT TimeSlotConversionError IO (PParams (BabbageEra StandardCrypto))
223+
mkPParams pabConf =
224+
liftEither
225+
. fmap (CAPI.toLedgerPParams CAPI.ShelleyBasedEraBabbage)
226+
. maybeToEither (TimeSlotConversionError "No protocol params found")
227+
$ pcProtocolParams pabConf

0 commit comments

Comments
 (0)