Skip to content

Commit 674149d

Browse files
committed
fourmolize
1 parent 7dde03f commit 674149d

File tree

6 files changed

+45
-44
lines changed

6 files changed

+45
-44
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,20 @@ updateEpochStart syncEnv cache slotDetails isNewEpochEvent isBoundaryBlock = do
8080
let curEpochNo = unEpochNo $ sdEpochNo slotDetails
8181

8282
if
83-
-- The tip has been reached so now replace/update the epoch every block.
84-
| getSyncStatus slotDetails == SyncFollowing ->
85-
handleEpochWhenFollowing syncEnv cache mLastMapEpochFromCache mEpochBlockDiff curEpochNo
86-
-- When syncing we check if current block is the first block in an epoch.
87-
-- If so then it's time to put the previous epoch into the DB.
88-
| isNewEpochEvent ->
89-
updateEpochWhenSyncing syncEnv cache mEpochBlockDiff mLastMapEpochFromCache curEpochNo isBoundaryBlock
90-
-- we're syncing and the epochNo are the same so we just update the cache until above check passes.
91-
| otherwise ->
92-
handleEpochCachingWhenSyncing
93-
syncEnv
94-
cache
95-
mLastMapEpochFromCache
96-
mEpochBlockDiff
83+
-- The tip has been reached so now replace/update the epoch every block.
84+
| getSyncStatus slotDetails == SyncFollowing ->
85+
handleEpochWhenFollowing syncEnv cache mLastMapEpochFromCache mEpochBlockDiff curEpochNo
86+
-- When syncing we check if current block is the first block in an epoch.
87+
-- If so then it's time to put the previous epoch into the DB.
88+
| isNewEpochEvent ->
89+
updateEpochWhenSyncing syncEnv cache mEpochBlockDiff mLastMapEpochFromCache curEpochNo isBoundaryBlock
90+
-- we're syncing and the epochNo are the same so we just update the cache until above check passes.
91+
| otherwise ->
92+
handleEpochCachingWhenSyncing
93+
syncEnv
94+
cache
95+
mLastMapEpochFromCache
96+
mEpochBlockDiff
9797

9898
-----------------------------------------------------------------------------------------------------
9999
-- When Following

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ genericCountEpochStake ::
195195
LedgerState (ShelleyBlock p era) mk ->
196196
Maybe (Word64, EpochNo)
197197
genericCountEpochStake lstate =
198-
Just (delegationsLen, epoch)
198+
Just (delegationsLen, epoch)
199199
where
200200
epoch :: EpochNo
201201
epoch = EpochNo $ 1 + unEpochNo (Shelley.nesEL (Consensus.shelleyLedgerState lstate))
@@ -236,7 +236,7 @@ genericFullStakeSlice ::
236236
LedgerState (ShelleyBlock p era) mk ->
237237
StakeSliceRes
238238
genericFullStakeSlice lstate =
239-
Slice stakeSlice True
239+
Slice stakeSlice True
240240
where
241241
epoch :: EpochNo
242242
epoch = EpochNo $ 1 + unEpochNo (Shelley.nesEL (Consensus.shelleyLedgerState lstate))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
2525
import Cardano.DbSync.Era.Universal.Adjust (adjustEpochRewards)
2626
import Cardano.DbSync.Era.Universal.Epoch (insertPoolDepositRefunds, insertProposalRefunds, insertRewardRests, insertRewards)
2727
import Cardano.DbSync.Era.Universal.Insert.GovAction
28-
import Cardano.DbSync.Era.Universal.Validate (validateEpochStake, validateEpochRewards)
28+
import Cardano.DbSync.Era.Universal.Validate (validateEpochRewards, validateEpochStake)
2929
import Cardano.DbSync.Ledger.Event
3030
import Cardano.DbSync.Types
3131

3232
import Cardano.DbSync.Error (SyncNodeError)
33+
import Cardano.DbSync.Ledger.Types
3334
import Cardano.DbSync.Metrics (setDbEpochSyncDuration, setDbEpochSyncNumber)
3435
import Control.Concurrent.Class.MonadSTM.Strict (readTVarIO, writeTVar)
3536
import Control.Monad.Extra (whenJust)
@@ -38,7 +39,6 @@ import qualified Data.Set as Set
3839
import qualified Data.Text as Text
3940
import Data.Time (UTCTime, diffUTCTime, getCurrentTime)
4041
import Text.Printf (printf)
41-
import Cardano.DbSync.Ledger.Types
4242

4343
--------------------------------------------------------------------------------------------
4444
-- Insert LedgerEvents

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,27 @@ import qualified Data.Set as Set
2121
import GHC.Err (error)
2222

2323
import qualified Cardano.Db as DB
24+
import Cardano.DbSync.Api
25+
import Cardano.DbSync.Api.Types
2426
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
27+
import Cardano.DbSync.Era.Universal.Epoch
2528
import Cardano.DbSync.Error (SyncNodeError)
2629
import Cardano.DbSync.Ledger.Event
27-
import Cardano.DbSync.Types
2830
import Cardano.DbSync.Ledger.Types
29-
import qualified Data.Strict.Maybe as Strict
30-
import Cardano.DbSync.Api.Types
31-
import Cardano.DbSync.Api
32-
import Cardano.DbSync.Era.Universal.Epoch
31+
import Cardano.DbSync.Types
3332
import Cardano.DbSync.Util.Constraint
33+
import qualified Data.Strict.Maybe as Strict
3434

3535
validateEpochStake ::
3636
SyncEnv ->
3737
ApplyResult ->
3838
Bool ->
3939
ExceptT SyncNodeError DB.DbM ()
4040
validateEpochStake syncEnv applyRes firstCall = case apOldLedger applyRes of
41-
Strict.Just lstate | Just (expectedCount, epoch) <- Generic.countEpochStake (clsState lstate) -> do
42-
actualCount <- lift $ DB.queryNormalEpochStakeCount (unEpochNo epoch)
43-
if actualCount /= expectedCount then do
41+
Strict.Just lstate | Just (expectedCount, epoch) <- Generic.countEpochStake (clsState lstate) -> do
42+
actualCount <- lift $ DB.queryNormalEpochStakeCount (unEpochNo epoch)
43+
if actualCount /= expectedCount
44+
then do
4445
liftIO
4546
. logWarning tracer
4647
$ mconcat
@@ -56,18 +57,18 @@ validateEpochStake syncEnv applyRes firstCall = case apOldLedger applyRes of
5657
insertStakeSlice syncEnv slice
5758
when firstCall $ validateEpochStake syncEnv applyRes False
5859
else
59-
liftIO $ logInfo tracer
60-
$ mconcat
61-
[ "Validate Epoch Stake: total entries in epoch "
62-
, textShow (unEpochNo epoch)
63-
, " are "
64-
, textShow actualCount
65-
]
66-
_ -> pure ()
60+
liftIO $
61+
logInfo tracer $
62+
mconcat
63+
[ "Validate Epoch Stake: total entries in epoch "
64+
, textShow (unEpochNo epoch)
65+
, " are "
66+
, textShow actualCount
67+
]
68+
_ -> pure ()
6769
where
6870
tracer = getTrace syncEnv
6971

70-
7172
validateEpochRewards ::
7273
Trace IO Text ->
7374
Network ->

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ httpGetBytes manager request bytesToRead maxBytes url =
174174
( "application/json"
175175
`BS.isInfixOf` ct
176176
|| "application/ld+json"
177-
`BS.isInfixOf` ct
177+
`BS.isInfixOf` ct
178178
|| "text/plain"
179-
`BS.isInfixOf` ct
179+
`BS.isInfixOf` ct
180180
|| "binary/octet-stream"
181-
`BS.isInfixOf` ct
181+
`BS.isInfixOf` ct
182182
|| "application/octet-stream"
183-
`BS.isInfixOf` ct
183+
`BS.isInfixOf` ct
184184
|| "application/binary"
185-
`BS.isInfixOf` ct
185+
`BS.isInfixOf` ct
186186
)
187187
. left
188188
$ OCFErrBadContentType url (Text.decodeLatin1 ct)

cardano-db-tool/src/Cardano/DbTool/Validate/AdaPots.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ validateSumAdaPots = do
2121
let uniqueCount = List.length $ List.nubOrd (map accSumAdaPots xs)
2222

2323
if
24-
| uniqueCount == 0 -> error $ redText "No AdaPots entries found"
25-
| length xs == 1 -> putStrLn $ greenText "ok (but only one AdaPots entry found)"
26-
| uniqueCount == 1 -> putStrLn $ greenText "ok"
27-
| otherwise -> error $ redText (show uniqueCount ++ " unique AdaPots sums (should be 1)")
24+
| uniqueCount == 0 -> error $ redText "No AdaPots entries found"
25+
| length xs == 1 -> putStrLn $ greenText "ok (but only one AdaPots entry found)"
26+
| uniqueCount == 1 -> putStrLn $ greenText "ok"
27+
| otherwise -> error $ redText (show uniqueCount ++ " unique AdaPots sums (should be 1)")
2828

2929
-- -----------------------------------------------------------------------------
3030

0 commit comments

Comments
 (0)