Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Marconi.Cardano.Indexers.SyncHelper
Description
Provide standard query and helper functions to track the last sync points of an indexer
Synopsis
- syncTableCreation :: Query
- syncSetStablePoint :: SetLastStablePointQuery
- syncLastPointQuery :: GetLastStablePointQuery
- syncHistoryQuery :: Query
- mkSingleInsertSyncedSqliteIndexer :: forall m event param. (MonadIO m, MonadError IndexerError m, ToRow param, Point event ~ ChainPoint) => SQLiteDBLocation -> (Timed (Point event) event -> param) -> Query -> Query -> SQLRollbackPlan (Point event) -> m (SQLiteIndexer event)
- mkSyncedSqliteIndexer :: forall m event. (MonadIO m, MonadError IndexerError m, Point event ~ ChainPoint) => SQLiteDBLocation -> [Query] -> [[SQLInsertPlan event]] -> [SQLRollbackPlan (Point event)] -> m (SQLiteIndexer event)
Documentation
syncTableCreation :: Query #
A simple table to store the last stable point of an indexer.
Note that in Byron era, there can be multiple added blocks in the same slot. That explains why we
can't use the `PRIMARY KEY` constraint for slotNo
only.
syncSetStablePoint :: SetLastStablePointQuery #
Used to insert data in the snc table.
The parameter order is slotNo
, blockHeaderHash
.
This should not be used in general, as syncInsertPlan
provides a higher level function to
handle insertion of data.
The query ensure that we only replace the content on a greater slot.
Considering the issue of the blocks issued at the same slots during the Byron era, there is very few chance that the current implementation would lead to an issue. The problematic scenario would be:
- The indexer must index an event that in the second block of the two issue at the same slot at the end of an epoch of the Byron era.
- The indexer has stopped right after indexing this second block.
- On restart, another indexer is behind this second block.
syncLastPointQuery :: GetLastStablePointQuery #
Query for the last point of an indexer
syncHistoryQuery :: Query #
Query the last sync point up to the first immutable event
Used to find resuming points on restart.
mkSingleInsertSyncedSqliteIndexer #
Arguments
:: forall m event param. (MonadIO m, MonadError IndexerError m, ToRow param, Point event ~ ChainPoint) | |
=> SQLiteDBLocation | |
-> (Timed (Point event) event -> param) | |
-> Query | the creation query |
-> Query | the insert query |
-> SQLRollbackPlan (Point event) | the rollback query |
-> m (SQLiteIndexer event) |
A helper to create an indexer for Cardano for a single table, with an immutable point tracker
Arguments
:: forall m event. (MonadIO m, MonadError IndexerError m, Point event ~ ChainPoint) | |
=> SQLiteDBLocation | |
-> [Query] | cration statement |
-> [[SQLInsertPlan event]] | extract relevent data out of an event and store them |
-> [SQLRollbackPlan (Point event)] | the rollback queries |
-> m (SQLiteIndexer event) |
A helper to create an indexer for Cardano, with an immutable point tracker