@@ -44,15 +44,15 @@ import Cardano.Prelude
44
44
45
45
import qualified Cardano.Db as DB
46
46
import qualified Cardano.Db.Schema.Variants.TxOutAddress as VA
47
+ import Cardano.DbSync.Api (getTrace )
48
+ import Cardano.DbSync.Api.Types (EpochStatistics (.. ), SyncEnv (.. ))
47
49
import Cardano.DbSync.Cache.Epoch (rollbackMapEpochInCache )
48
50
import qualified Cardano.DbSync.Cache.FIFO as FIFO
49
51
import qualified Cardano.DbSync.Cache.LRU as LRU
50
52
import Cardano.DbSync.Cache.Types (CacheAction (.. ), CacheInternal (.. ), CacheStatistics (.. ), CacheStatus (.. ), StakeCache (.. ), shouldCache )
51
53
import qualified Cardano.DbSync.Era.Shelley.Generic.Util as Generic
52
54
import Cardano.DbSync.Era.Shelley.Query
53
55
import Cardano.DbSync.Types
54
- import Cardano.DbSync.Api.Types (SyncEnv (.. ), EpochStatistics (.. ))
55
- import Cardano.DbSync.Api (getTrace )
56
56
57
57
-- Rollbacks make everything harder and the same applies to caching.
58
58
-- After a rollback db entries are deleted, so we need to clean the same
@@ -552,76 +552,76 @@ withCacheOptimisationCheck ci ifOptimised ifNotOptimised = do
552
552
-- Creds
553
553
hitCreds :: SyncEnv -> IO ()
554
554
hitCreds syncEnv =
555
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
556
- epochStats { elsCaches = (elsCaches epochStats) { credsHits = 1 + credsHits (elsCaches epochStats), credsQueries = 1 + credsQueries (elsCaches epochStats) } }
555
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
556
+ epochStats {elsCaches = (elsCaches epochStats) {credsHits = 1 + credsHits (elsCaches epochStats), credsQueries = 1 + credsQueries (elsCaches epochStats)} }
557
557
558
558
missCreds :: SyncEnv -> IO ()
559
559
missCreds syncEnv =
560
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
561
- epochStats { elsCaches = (elsCaches epochStats) { credsQueries = 1 + credsQueries (elsCaches epochStats) } }
560
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
561
+ epochStats {elsCaches = (elsCaches epochStats) {credsQueries = 1 + credsQueries (elsCaches epochStats)} }
562
562
563
563
-- Pools
564
564
hitPools :: SyncEnv -> IO ()
565
565
hitPools syncEnv =
566
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
567
- epochStats { elsCaches = (elsCaches epochStats) { poolsHits = 1 + poolsHits (elsCaches epochStats), poolsQueries = 1 + poolsQueries (elsCaches epochStats) } }
566
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
567
+ epochStats {elsCaches = (elsCaches epochStats) {poolsHits = 1 + poolsHits (elsCaches epochStats), poolsQueries = 1 + poolsQueries (elsCaches epochStats)} }
568
568
569
569
missPools :: SyncEnv -> IO ()
570
570
missPools syncEnv =
571
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
572
- epochStats { elsCaches = (elsCaches epochStats) { poolsQueries = 1 + poolsQueries (elsCaches epochStats) } }
571
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
572
+ epochStats {elsCaches = (elsCaches epochStats) {poolsQueries = 1 + poolsQueries (elsCaches epochStats)} }
573
573
574
574
-- Datum
575
575
hitDatum :: SyncEnv -> IO ()
576
576
hitDatum syncEnv =
577
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
578
- epochStats { elsCaches = (elsCaches epochStats) { datumHits = 1 + datumHits (elsCaches epochStats), datumQueries = 1 + datumQueries (elsCaches epochStats) } }
577
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
578
+ epochStats {elsCaches = (elsCaches epochStats) {datumHits = 1 + datumHits (elsCaches epochStats), datumQueries = 1 + datumQueries (elsCaches epochStats)} }
579
579
580
580
missDatum :: SyncEnv -> IO ()
581
581
missDatum syncEnv =
582
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
583
- epochStats { elsCaches = (elsCaches epochStats) { datumQueries = 1 + datumQueries (elsCaches epochStats) } }
582
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
583
+ epochStats {elsCaches = (elsCaches epochStats) {datumQueries = 1 + datumQueries (elsCaches epochStats)} }
584
584
585
585
-- Assets
586
586
hitMAssets :: SyncEnv -> IO ()
587
587
hitMAssets syncEnv =
588
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
589
- epochStats { elsCaches = (elsCaches epochStats) { multiAssetsHits = 1 + multiAssetsHits (elsCaches epochStats), multiAssetsQueries = 1 + multiAssetsQueries (elsCaches epochStats) } }
588
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
589
+ epochStats {elsCaches = (elsCaches epochStats) {multiAssetsHits = 1 + multiAssetsHits (elsCaches epochStats), multiAssetsQueries = 1 + multiAssetsQueries (elsCaches epochStats)} }
590
590
591
591
missMAssets :: SyncEnv -> IO ()
592
592
missMAssets syncEnv =
593
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
594
- epochStats { elsCaches = (elsCaches epochStats) { multiAssetsQueries = 1 + multiAssetsQueries (elsCaches epochStats) } }
593
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
594
+ epochStats {elsCaches = (elsCaches epochStats) {multiAssetsQueries = 1 + multiAssetsQueries (elsCaches epochStats)} }
595
595
596
596
-- Address
597
597
hitAddress :: SyncEnv -> IO ()
598
598
hitAddress syncEnv =
599
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
600
- epochStats { elsCaches = (elsCaches epochStats) { addressHits = 1 + addressHits (elsCaches epochStats), addressQueries = 1 + addressQueries (elsCaches epochStats) } }
599
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
600
+ epochStats {elsCaches = (elsCaches epochStats) {addressHits = 1 + addressHits (elsCaches epochStats), addressQueries = 1 + addressQueries (elsCaches epochStats)} }
601
601
602
602
missAddress :: SyncEnv -> IO ()
603
603
missAddress syncEnv =
604
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
605
- epochStats { elsCaches = (elsCaches epochStats) { addressQueries = 1 + addressQueries (elsCaches epochStats) } }
604
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
605
+ epochStats {elsCaches = (elsCaches epochStats) {addressQueries = 1 + addressQueries (elsCaches epochStats)} }
606
606
607
607
-- Blocks
608
608
hitPBlock :: SyncEnv -> IO ()
609
609
hitPBlock syncEnv =
610
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
611
- epochStats { elsCaches = (elsCaches epochStats) { prevBlockHits = 1 + prevBlockHits (elsCaches epochStats), prevBlockQueries = 1 + prevBlockQueries (elsCaches epochStats) } }
610
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
611
+ epochStats {elsCaches = (elsCaches epochStats) {prevBlockHits = 1 + prevBlockHits (elsCaches epochStats), prevBlockQueries = 1 + prevBlockQueries (elsCaches epochStats)} }
612
612
613
613
missPrevBlock :: SyncEnv -> IO ()
614
614
missPrevBlock syncEnv =
615
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
616
- epochStats { elsCaches = (elsCaches epochStats) { prevBlockQueries = 1 + prevBlockQueries (elsCaches epochStats) } }
615
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
616
+ epochStats {elsCaches = (elsCaches epochStats) {prevBlockQueries = 1 + prevBlockQueries (elsCaches epochStats)} }
617
617
618
618
-- TxIds
619
619
hitTxIds :: SyncEnv -> IO ()
620
620
hitTxIds syncEnv =
621
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
622
- epochStats { elsCaches = (elsCaches epochStats) { txIdsHits = 1 + txIdsHits (elsCaches epochStats), txIdsQueries = 1 + txIdsQueries (elsCaches epochStats) } }
621
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
622
+ epochStats {elsCaches = (elsCaches epochStats) {txIdsHits = 1 + txIdsHits (elsCaches epochStats), txIdsQueries = 1 + txIdsQueries (elsCaches epochStats)} }
623
623
624
624
missTxIds :: SyncEnv -> IO ()
625
625
missTxIds syncEnv =
626
- atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
627
- epochStats { elsCaches = (elsCaches epochStats) { txIdsQueries = 1 + txIdsQueries (elsCaches epochStats) } }
626
+ atomically $ modifyTVar (envEpochStatistics syncEnv) $ \ epochStats ->
627
+ epochStats {elsCaches = (elsCaches epochStats) {txIdsQueries = 1 + txIdsQueries (elsCaches epochStats)} }
0 commit comments