4
4
5
5
import Cardano.Db (
6
6
EntityField (.. ),
7
+ OffChainPoolData ,
7
8
PoolHashId ,
8
9
PoolMetaHash (.. ),
9
10
PoolMetadataRef ,
10
- PoolOfflineData ,
11
11
PoolRetire ,
12
12
PoolUrl (.. ),
13
13
runDbNoLoggingEnv ,
14
14
unValue4 ,
15
15
)
16
- import Cardano.DbSync.Era.Shelley.Offline .Http (
16
+ import Cardano.DbSync.Era.Shelley.OffChain .Http (
17
17
FetchError (.. ),
18
- httpGetPoolOfflineData ,
18
+ httpGetOffChainPoolData ,
19
19
parsePoolUrl ,
20
20
)
21
21
import Control.Monad (foldM )
@@ -49,18 +49,18 @@ import Network.HTTP.Client.TLS (tlsManagerSettings)
49
49
main :: IO ()
50
50
main = do
51
51
manager <- Http. newManager tlsManagerSettings
52
- xs <- runDbNoLoggingEnv queryTestOfflineData
53
- putStrLn $ " testOfflineDataFetch : " ++ show (length xs) ++ " tests to run."
52
+ xs <- runDbNoLoggingEnv queryTestOffChainData
53
+ putStrLn $ " testOffChainPoolDataFetch : " ++ show (length xs) ++ " tests to run."
54
54
tfs <- foldM (testOne manager) emptyTestFailure xs
55
55
reportTestFailures tfs
56
56
where
57
- testOne :: Http. Manager -> TestFailure -> TestOffline -> IO TestFailure
58
- testOne manager ! accum testOffline = do
59
- let poolUrl = toUrl testOffline
60
- mHash = Just $ toHash testOffline
57
+ testOne :: Http. Manager -> TestFailure -> TestOffChain -> IO TestFailure
58
+ testOne manager ! accum testPoolOffChain = do
59
+ let poolUrl = toUrl testPoolOffChain
60
+ mHash = Just $ toHash testPoolOffChain
61
61
eres <- runExceptT $ do
62
62
request <- parsePoolUrl poolUrl
63
- httpGetPoolOfflineData manager request poolUrl mHash
63
+ httpGetOffChainPoolData manager request poolUrl mHash
64
64
case eres of
65
65
Left err -> do
66
66
print err
@@ -70,7 +70,7 @@ main = do
70
70
71
71
-- -------------------------------------------------------------------------------------------------
72
72
73
- data TestOffline = TestOffline
73
+ data TestOffChain = TestOffChain
74
74
{ toTicker :: ! Text
75
75
, toUrl :: ! PoolUrl
76
76
, toHash :: ! PoolMetaHash
@@ -125,35 +125,35 @@ reportTestFailures tf = do
125
125
, " ConnectionFailure : " ++ show (tfConnectionFailure tf)
126
126
]
127
127
128
- -- reportTestOffline :: TestOffline -> IO ()
129
- -- reportTestOffline tof = Text.putStrLn $ mconcat [ toTicker tof, " ", unPoolUrl (toUrl tof) ]
128
+ -- reportTestOffChain :: TestOffChain -> IO ()
129
+ -- reportTestOffChain tof = Text.putStrLn $ mconcat [ toTicker tof, " ", unPoolUrl (toUrl tof) ]
130
130
131
- queryTestOfflineData :: MonadIO m => ReaderT SqlBackend m [TestOffline ]
132
- queryTestOfflineData = do
131
+ queryTestOffChainData :: MonadIO m => ReaderT SqlBackend m [TestOffChain ]
132
+ queryTestOffChainData = do
133
133
res <- select $ do
134
134
(pod :& pmr) <-
135
135
from
136
- $ table @ PoolOfflineData
136
+ $ table @ OffChainPoolData
137
137
`innerJoin` table @ PoolMetadataRef
138
- `on` (\ (pod :& pmr) -> pod ^. PoolOfflineDataPmrId ==. pmr ^. PoolMetadataRefId )
139
- where_ $ notExists (from (table @ PoolRetire ) >>= \ pr -> where_ (pod ^. PoolOfflineDataPoolId ==. pr ^. PoolRetireHashId ))
138
+ `on` (\ (pod :& pmr) -> pod ^. OffChainPoolDataPmrId ==. pmr ^. PoolMetadataRefId )
139
+ where_ $ notExists (from (table @ PoolRetire ) >>= \ pr -> where_ (pod ^. OffChainPoolDataPoolId ==. pr ^. PoolRetireHashId ))
140
140
pure
141
- ( pod ^. PoolOfflineDataTickerName
141
+ ( pod ^. OffChainPoolDataTickerName
142
142
, pmr ^. PoolMetadataRefUrl
143
143
, pmr ^. PoolMetadataRefHash
144
- , pod ^. PoolOfflineDataPoolId
144
+ , pod ^. OffChainPoolDataPoolId
145
145
)
146
146
pure . organise $ map (convert . unValue4) res
147
147
where
148
- convert :: (Text , PoolUrl , ByteString , PoolHashId ) -> (PoolHashId , TestOffline )
148
+ convert :: (Text , PoolUrl , ByteString , PoolHashId ) -> (PoolHashId , TestOffChain )
149
149
convert (tname, url, hash, poolId) =
150
150
( poolId
151
- , TestOffline
151
+ , TestOffChain
152
152
{ toTicker = tname
153
153
, toUrl = url
154
154
, toHash = PoolMetaHash hash
155
155
}
156
156
)
157
157
158
- organise :: [(PoolHashId , TestOffline )] -> [TestOffline ]
158
+ organise :: [(PoolHashId , TestOffChain )] -> [TestOffChain ]
159
159
organise = map (List. head . map snd . List. sortOn (Down . fst )) . List. groupOn fst
0 commit comments