Skip to content

Commit d1a6183

Browse files
committed
rename offline to offchain
1 parent 083d302 commit d1a6183

File tree

36 files changed

+467
-465
lines changed

36 files changed

+467
-465
lines changed

Readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ possible solutions.
8989
* [Docker][Docker]: Instruction for docker-compose, and building the images using nix.
9090
* [ERD][ERD]: The entity relationship diagram.
9191
* [Example SQL queries][ExampleQueries]: Some example SQL and Haskell/Esqueleto queries.
92-
* [PoolOfflineData][PoolOfflineData]: Explanation of how stake pool offline data is retried.
92+
* [OffChainPoolData][OffChainPoolData]: Explanation of how stake pool offchain data is retried.
9393
* [Schema Documentation][Schema Documentation]: The database schema documentation.
9494
* [Schema Management][Schema Management]: How the database schema is managed and modified.
9595
* [StateSnapshot][StateSnapshot]: Document the creation and restoration of state snapshot files.
@@ -103,7 +103,7 @@ possible solutions.
103103
[ERD]: doc/ERD.png
104104
[ExampleQueries]: doc/interesting-queries.md
105105
[PostgresView]: https://www.postgresql.org/docs/current/sql-createview.html
106-
[PoolOfflineData]: doc/pool-offline-data.md
106+
[OffChainPoolData]: doc/pool-offchain-data.md
107107
[Schema Documentation]: doc/schema.md
108108
[Schema Management]: doc/schema-management.md
109109
[StateSnapshot]: doc/state-snapshot.md

cardano-chain-gen/test/Test/Cardano/Db/Mock/Config.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ data CommandLineArgs = CommandLineArgs
108108
, claHasMultiAssets :: Bool
109109
, claHasMetadata :: Bool
110110
, claHasPlutusExtra :: Bool
111-
, claHasOfflineData :: Bool
111+
, claHasOffChainData :: Bool
112112
, claTurboMode :: Bool
113113
, claFullMode :: Bool
114114
, claMigrateConsumed :: Bool
@@ -260,7 +260,7 @@ mkSyncNodeParams staticDir mutableDir CommandLineArgs {..} = do
260260
, enpHasMultiAssets = claHasMultiAssets
261261
, enpHasMetadata = claHasMetadata
262262
, enpHasPlutusExtra = True
263-
, enpHasOfflineData = True
263+
, enpHasOffChainPoolData = True
264264
, enpTurboMode = False
265265
, enpFullMode = True
266266
, enpMigrateConsumed = claMigrateConsumed
@@ -283,7 +283,7 @@ initCommandLineArgs =
283283
, claHasMultiAssets = True
284284
, claHasMetadata = True
285285
, claHasPlutusExtra = True
286-
, claHasOfflineData = True
286+
, claHasOffChainData = True
287287
, claTurboMode = False
288288
, claFullMode = True
289289
, claMigrateConsumed = False

cardano-db-sync/app/cardano-db-sync.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pRunDbSyncNode =
7878
<*> pHasMultiAssets
7979
<*> pHasMetadata
8080
<*> pHasPlutusExtra
81-
<*> pHasOfflineData
81+
<*> pHasOffChainPoolData
8282
<*> pTurboMode
8383
<*> pFullMode
8484
<*> pMigrateConsumed
@@ -231,13 +231,13 @@ pHasPlutusExtra =
231231
<> Opt.help "Disables most tables and entries related to plutus and scripts."
232232
)
233233

234-
pHasOfflineData :: Parser Bool
235-
pHasOfflineData =
234+
pHasOffChainPoolData :: Parser Bool
235+
pHasOffChainPoolData =
236236
Opt.flag
237237
True
238238
False
239-
( Opt.long "disable-offline-data"
240-
<> Opt.help "Disables fetching pool offline metadata."
239+
( Opt.long "disable-offchain-pool-data"
240+
<> Opt.help "Disables fetching pool offchain metadata."
241241
)
242242

243243
pTurboMode :: Parser Bool

cardano-db-sync/app/http-get-json-metadata.hs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import Cardano.Db (PoolMetaHash (..), PoolUrl (..))
44
import Cardano.DbSync (
55
FetchError (..),
6-
SimplifiedPoolOfflineData (..),
7-
httpGetPoolOfflineData,
6+
SimplifiedOffChainPoolData (..),
7+
httpGetOffChainPoolData,
88
parsePoolUrl,
99
)
1010
import Cardano.DbSync.Error (runOrThrowIO)
@@ -51,7 +51,7 @@ usageExit = do
5151
, " " ++ name ++ "<pool metadata utl>"
5252
, " " ++ name ++ "<pool metadata utl> <metadata hash in hex>"
5353
, ""
54-
, "A debug/test program to debug the pool offline metadata fetch mechanism.\n"
54+
, "A debug/test program to debug the pool offchain metadata fetch mechanism.\n"
5555
]
5656
exitFailure
5757

@@ -61,13 +61,13 @@ runHttpGet :: PoolUrl -> Maybe PoolMetaHash -> IO ()
6161
runHttpGet poolUrl mHash =
6262
reportSuccess =<< runOrThrowIO (runExceptT httpGet)
6363
where
64-
httpGet :: ExceptT FetchError IO SimplifiedPoolOfflineData
64+
httpGet :: ExceptT FetchError IO SimplifiedOffChainPoolData
6565
httpGet = do
6666
request <- parsePoolUrl poolUrl
6767
manager <- liftIO $ Http.newManager tlsManagerSettings
68-
httpGetPoolOfflineData manager request poolUrl mHash
68+
httpGetOffChainPoolData manager request poolUrl mHash
6969

70-
reportSuccess :: SimplifiedPoolOfflineData -> IO ()
70+
reportSuccess :: SimplifiedOffChainPoolData -> IO ()
7171
reportSuccess spod = do
7272
case spodContentType spod of
7373
Nothing -> putStrLn $ orangeText "Warning: No HTTP content-type returned in HTTP response (this should be fixed)."

cardano-db-sync/app/test-http-get-json-metadata.hs

+23-23
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
import Cardano.Db (
66
EntityField (..),
7+
OffChainPoolData,
78
PoolHashId,
89
PoolMetaHash (..),
910
PoolMetadataRef,
10-
PoolOfflineData,
1111
PoolRetire,
1212
PoolUrl (..),
1313
runDbNoLoggingEnv,
1414
unValue4,
1515
)
16-
import Cardano.DbSync.Era.Shelley.Offline.Http (
16+
import Cardano.DbSync.Era.Shelley.OffChain.Http (
1717
FetchError (..),
18-
httpGetPoolOfflineData,
18+
httpGetOffChainPoolData,
1919
parsePoolUrl,
2020
)
2121
import Control.Monad (foldM)
@@ -49,18 +49,18 @@ import Network.HTTP.Client.TLS (tlsManagerSettings)
4949
main :: IO ()
5050
main = do
5151
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."
5454
tfs <- foldM (testOne manager) emptyTestFailure xs
5555
reportTestFailures tfs
5656
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
6161
eres <- runExceptT $ do
6262
request <- parsePoolUrl poolUrl
63-
httpGetPoolOfflineData manager request poolUrl mHash
63+
httpGetOffChainPoolData manager request poolUrl mHash
6464
case eres of
6565
Left err -> do
6666
print err
@@ -70,7 +70,7 @@ main = do
7070

7171
-- -------------------------------------------------------------------------------------------------
7272

73-
data TestOffline = TestOffline
73+
data TestOffChain = TestOffChain
7474
{ toTicker :: !Text
7575
, toUrl :: !PoolUrl
7676
, toHash :: !PoolMetaHash
@@ -125,35 +125,35 @@ reportTestFailures tf = do
125125
, " ConnectionFailure : " ++ show (tfConnectionFailure tf)
126126
]
127127

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) ]
130130

131-
queryTestOfflineData :: MonadIO m => ReaderT SqlBackend m [TestOffline]
132-
queryTestOfflineData = do
131+
queryTestOffChainData :: MonadIO m => ReaderT SqlBackend m [TestOffChain]
132+
queryTestOffChainData = do
133133
res <- select $ do
134134
(pod :& pmr) <-
135135
from
136-
$ table @PoolOfflineData
136+
$ table @OffChainPoolData
137137
`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))
140140
pure
141-
( pod ^. PoolOfflineDataTickerName
141+
( pod ^. OffChainPoolDataTickerName
142142
, pmr ^. PoolMetadataRefUrl
143143
, pmr ^. PoolMetadataRefHash
144-
, pod ^. PoolOfflineDataPoolId
144+
, pod ^. OffChainPoolDataPoolId
145145
)
146146
pure . organise $ map (convert . unValue4) res
147147
where
148-
convert :: (Text, PoolUrl, ByteString, PoolHashId) -> (PoolHashId, TestOffline)
148+
convert :: (Text, PoolUrl, ByteString, PoolHashId) -> (PoolHashId, TestOffChain)
149149
convert (tname, url, hash, poolId) =
150150
( poolId
151-
, TestOffline
151+
, TestOffChain
152152
{ toTicker = tname
153153
, toUrl = url
154154
, toHash = PoolMetaHash hash
155155
}
156156
)
157157

158-
organise :: [(PoolHashId, TestOffline)] -> [TestOffline]
158+
organise :: [(PoolHashId, TestOffChain)] -> [TestOffChain]
159159
organise = map (List.head . map snd . List.sortOn (Down . fst)) . List.groupOn fst

cardano-db-sync/cardano-db-sync.cabal

+5-5
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ library
8787
Cardano.DbSync.Era.Shelley.Insert
8888
Cardano.DbSync.Era.Shelley.Insert.Epoch
8989
Cardano.DbSync.Era.Shelley.Insert.Grouped
90-
Cardano.DbSync.Era.Shelley.Offline
91-
Cardano.DbSync.Era.Shelley.Offline.FetchQueue
92-
Cardano.DbSync.Era.Shelley.Offline.Http
93-
Cardano.DbSync.Era.Shelley.Offline.Query
94-
Cardano.DbSync.Era.Shelley.Offline.Types
90+
Cardano.DbSync.Era.Shelley.OffChain
91+
Cardano.DbSync.Era.Shelley.OffChain.FetchQueue
92+
Cardano.DbSync.Era.Shelley.OffChain.Http
93+
Cardano.DbSync.Era.Shelley.OffChain.Query
94+
Cardano.DbSync.Era.Shelley.OffChain.Types
9595
Cardano.DbSync.Era.Shelley.Query
9696
Cardano.DbSync.Era.Shelley.Validate
9797

cardano-db-sync/src/Cardano/DbSync.hs

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ module Cardano.DbSync (
2020
runDbSync,
2121
-- For testing and debugging
2222
FetchError (..),
23-
SimplifiedPoolOfflineData (..),
24-
httpGetPoolOfflineData,
23+
SimplifiedOffChainPoolData (..),
24+
httpGetOffChainPoolData,
2525
parsePoolUrl,
2626
) where
2727

@@ -46,10 +46,10 @@ import Cardano.DbSync.Config.Types (
4646
import Cardano.DbSync.Database
4747
import Cardano.DbSync.DbAction
4848
import Cardano.DbSync.Era
49-
import Cardano.DbSync.Era.Shelley.Offline.Http (
49+
import Cardano.DbSync.Era.Shelley.OffChain.Http (
5050
FetchError (..),
51-
SimplifiedPoolOfflineData (..),
52-
httpGetPoolOfflineData,
51+
SimplifiedOffChainPoolData (..),
52+
httpGetOffChainPoolData,
5353
parsePoolUrl,
5454
spodJson,
5555
)
@@ -197,7 +197,7 @@ runSyncNode metricsSetters trce iomgr dbConnString ranMigrations runMigrationFnc
197197
id
198198
[ runDbThread syncEnv metricsSetters threadChannels
199199
, runSyncNodeClient metricsSetters syncEnv iomgr trce threadChannels (enpSocketPath syncNodeParams)
200-
, runOfflineFetchThread syncEnv
200+
, runOffChainFetchThread syncEnv
201201
, runLedgerStateWriteThread (getTrace syncEnv) (envLedgerEnv syncEnv)
202202
]
203203
where
@@ -241,7 +241,7 @@ extractSyncOptions snp aop =
241241
{ ioMultiAssets = enpHasMultiAssets snp
242242
, ioMetadata = enpHasMetadata snp
243243
, ioPlutusExtra = enpHasPlutusExtra snp
244-
, ioOfflineData = enpHasOfflineData snp
244+
, ioOffChainPoolData = enpHasOffChainPoolData snp
245245
}
246246

247247
startupReport :: Trace IO Text -> Bool -> SyncNodeParams -> IO ()
@@ -259,7 +259,7 @@ startupReport trce aop params = do
259259
logInfo trce $ mconcat ["Option disable-multiassets: ", textShow (not $ enpHasMultiAssets params)]
260260
logInfo trce $ mconcat ["Option disable-metadata: ", textShow (not $ enpHasMetadata params)]
261261
logInfo trce $ mconcat ["Option disable-plutus-extra: ", textShow (not $ enpHasPlutusExtra params)]
262-
logInfo trce $ mconcat ["Option disable-offline-data: ", textShow (not $ enpHasOfflineData params)]
262+
logInfo trce $ mconcat ["Option disable-offchain-pool-data: ", textShow (not $ enpHasOffChainPoolData params)]
263263
logInfo trce $ mconcat ["Option turbo: ", textShow (enpTurboMode params)]
264264
logInfo trce $ mconcat ["Option full: ", textShow (enpFullMode params)]
265265
logInfo trce $ mconcat ["Enviroment variable DbSyncAbortOnPanic: ", textShow aop]

cardano-db-sync/src/Cardano/DbSync/Api.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ mkSyncEnv trce connString backend syncOptions protoInfo nw nwMagic systemStart s
357357
, envIsFixed = fixDataVar
358358
, envLedgerEnv = ledgerEnvType
359359
, envNetworkMagic = nwMagic
360-
, envOfflineResultQueue = orq
361-
, envOfflineWorkQueue = owq
360+
, envOffChainPoolResultQueue = orq
361+
, envOffChainPoolWorkQueue = owq
362362
, envOptions = syncOptions
363363
, envProtocol = SyncProtocolCardano
364364
, envPruneConsumeMigration = pcm

cardano-db-sync/src/Cardano/DbSync/Api/Types.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Cardano.DbSync.Cache.Types (Cache)
1818
import Cardano.DbSync.Config.Types (SyncProtocol)
1919
import Cardano.DbSync.Ledger.Types (HasLedgerEnv)
2020
import Cardano.DbSync.LocalStateQuery (NoLedgerEnv)
21-
import Cardano.DbSync.Types (FetchResult, PoolFetchRetry)
21+
import Cardano.DbSync.Types (OffChainPoolFetchRetry, OffChainPoolResult)
2222
import Cardano.Prelude (Bool, Eq, IO, Show, Word64)
2323
import Cardano.Slotting.Slot (EpochNo (..))
2424
import Control.Concurrent.Class.MonadSTM.Strict (
@@ -44,8 +44,8 @@ data SyncEnv = SyncEnv
4444
, envIsFixed :: !(StrictTVar IO FixesRan)
4545
, envLedgerEnv :: !LedgerEnv
4646
, envNetworkMagic :: !NetworkMagic
47-
, envOfflineResultQueue :: !(StrictTBQueue IO FetchResult)
48-
, envOfflineWorkQueue :: !(StrictTBQueue IO PoolFetchRetry)
47+
, envOffChainPoolResultQueue :: !(StrictTBQueue IO OffChainPoolResult)
48+
, envOffChainPoolWorkQueue :: !(StrictTBQueue IO OffChainPoolFetchRetry)
4949
, envOptions :: !SyncOptions
5050
, envProtocol :: !SyncProtocol
5151
, envPruneConsumeMigration :: !DB.PruneConsumeMigration
@@ -68,7 +68,7 @@ data InsertOptions = InsertOptions
6868
{ ioMultiAssets :: !Bool
6969
, ioMetadata :: !Bool
7070
, ioPlutusExtra :: !Bool
71-
, ioOfflineData :: !Bool
71+
, ioOffChainPoolData :: !Bool
7272
}
7373

7474
-- A representation of if we are using a ledger or not given CLI options

cardano-db-sync/src/Cardano/DbSync/Config/Types.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ data SyncNodeParams = SyncNodeParams
7070
, enpHasMultiAssets :: !Bool
7171
, enpHasMetadata :: !Bool
7272
, enpHasPlutusExtra :: !Bool
73-
, enpHasOfflineData :: !Bool
73+
, enpHasOffChainPoolData :: !Bool
7474
, enpTurboMode :: !Bool
7575
, enpFullMode :: !Bool
7676
, enpMigrateConsumed :: !Bool

cardano-db-sync/src/Cardano/DbSync/Era.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Cardano.DbSync.Api.Types (SyncEnv)
1111
import Cardano.DbSync.Config
1212
import qualified Cardano.DbSync.Era.Byron.Genesis as Byron
1313
import qualified Cardano.DbSync.Era.Shelley.Genesis as Shelley
14-
import Cardano.DbSync.Era.Shelley.Offline as X
14+
import Cardano.DbSync.Era.Shelley.OffChain as X
1515
import Cardano.DbSync.Error
1616
import Cardano.Prelude
1717

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import Cardano.DbSync.Era.Shelley.Generic.Metadata (
4949
import Cardano.DbSync.Era.Shelley.Generic.ParamProposal
5050
import Cardano.DbSync.Era.Shelley.Insert.Epoch
5151
import Cardano.DbSync.Era.Shelley.Insert.Grouped
52-
import Cardano.DbSync.Era.Shelley.Offline
52+
import Cardano.DbSync.Era.Shelley.OffChain
5353
import Cardano.DbSync.Era.Shelley.Query
5454
import Cardano.DbSync.Era.Util (liftLookupFail, safeDecodeToJson)
5555
import Cardano.DbSync.Error
@@ -198,11 +198,11 @@ insertShelleyBlock syncEnv shouldLog withinTwoMins withinHalfHour blk details is
198198

199199
insertStakeSlice syncEnv $ apStakeSlice applyResult
200200

201-
when (ioOfflineData iopts && unBlockNo (Generic.blkBlockNo blk) `mod` offlineModBase == 0)
201+
when (ioOffChainPoolData iopts && unBlockNo (Generic.blkBlockNo blk) `mod` offChainModBase == 0)
202202
. lift
203203
$ do
204-
insertOfflineResults tracer (envOfflineResultQueue syncEnv)
205-
loadOfflineWorkQueue tracer (envOfflineWorkQueue syncEnv)
204+
insertOffChainResults tracer (envOffChainPoolResultQueue syncEnv)
205+
loadOffChainWorkQueue tracer (envOffChainPoolWorkQueue syncEnv)
206206
where
207207
iopts = getInsertOptions syncEnv
208208

@@ -223,8 +223,8 @@ insertShelleyBlock syncEnv shouldLog withinTwoMins withinHalfHour blk details is
223223
Generic.Shelley -> "insertShelleyBlock"
224224
other -> mconcat ["insertShelleyBlock(", textShow other, ")"]
225225

226-
offlineModBase :: Word64
227-
offlineModBase = if withinTwoMins then 10 else 2000
226+
offChainModBase :: Word64
227+
offChainModBase = if withinTwoMins then 10 else 2000
228228

229229
tracer :: Trace IO Text
230230
tracer = getTrace syncEnv

0 commit comments

Comments
 (0)