haskoin-store 0.40.21 → 0.40.22
raw patch · 2 files changed
+26/−8 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- haskoin-store.cabal +2/−2
- src/Haskoin/Store/Cache.hs +24/−6
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a00a81763665669851ea7116eef061df94a889676055da250938372cb8ddbe18+-- hash: 3ef4d7acbc42cf65fef64eae75b754c1bab3b375f5a47010f12170c6c06e8f4e name: haskoin-store-version: 0.40.21+version: 0.40.22 synopsis: Storage and index for Bitcoin and Bitcoin Cash description: Please see the README on GitHub at <https://github.com/haskoin/haskoin-store#readme> category: Bitcoin, Finance, Network
src/Haskoin/Store/Cache.hs view
@@ -119,11 +119,16 @@ } data CacheMetrics = CacheMetrics- { cacheHits :: !Metrics.Counter- , cacheMisses :: !Metrics.Counter- , cacheIgnore :: !Metrics.Counter- , cacheRefreshes :: !Metrics.Counter- , cacheIndexTime :: !StatDist+ { cacheHits :: !Metrics.Counter+ , cacheMisses :: !Metrics.Counter+ , cacheIgnore :: !Metrics.Counter+ , cacheRefreshes :: !Metrics.Counter+ , cacheLockAcquired :: !Metrics.Counter+ , cacheLockReleased :: !Metrics.Counter+ , cacheLockFailed :: !Metrics.Counter+ , cacheIndexTime :: !StatDist+ , cacheMempoolSyncTime :: !StatDist+ , cacheBlockSyncTime :: !StatDist } newCacheMetrics :: MonadIO m => Metrics.Store -> m CacheMetrics@@ -132,7 +137,12 @@ cacheMisses <- c "misses" cacheIgnore <- c "ignore" cacheRefreshes <- c "refreshes"+ cacheLockAcquired <- c "lock_acquired"+ cacheLockReleased <- c "lock_released"+ cacheLockFailed <- c "lock_failed" cacheIndexTime <- d "index_time_ms"+ cacheMempoolSyncTime <- d "mempool_sync_time_ms"+ cacheBlockSyncTime <- d "block_sync_time_ms" return CacheMetrics{..} where c x = Metrics.createCounter ("cache." <> x) s@@ -500,21 +510,26 @@ Right Redis.Ok -> do $(logDebugS) "Cache" $ "Acquired lock with value " <> cs (show rnd)+ incrementCounter cacheLockAcquired return (Just rnd) Right Redis.Pong -> do $(logErrorS) "Cache" "Unexpected pong when acquiring lock"+ incrementCounter cacheLockFailed return Nothing Right (Redis.Status s) -> do $(logErrorS) "Cache" $ "Unexpected status acquiring lock: " <> cs s+ incrementCounter cacheLockFailed return Nothing Left (Redis.Bulk Nothing) -> do $(logDebugS) "Cache" "Lock already taken"+ incrementCounter cacheLockFailed return Nothing Left e -> do $(logErrorS) "Cache" "Error when trying to acquire lock"+ incrementCounter cacheLockFailed throwIO (RedisError e) where go rnd = do@@ -544,6 +559,7 @@ $(logDebugS) "Cache" $ "Released lock with value " <> cs (show i)+ incrementCounter cacheLockReleased else $(logErrorS) "Cache" $ "Could not release lock: value is not " <>@@ -750,6 +766,7 @@ => BlockHash -> CacheX m () importBlockC bh = withLockForever $+ withMetrics cacheBlockSyncTime $ cacheGetHead >>= \case Nothing -> go Just cb ->@@ -1035,7 +1052,8 @@ => CacheX m () syncMempoolC = toInteger <$> asks cacheRefresh >>= \refresh ->- void . withLockForever . withCool "cool" (refresh * 9 `div` 10) $ do+ void . withLockForever . withCool "cool" (refresh * 9 `div` 10) $+ withMetrics cacheMempoolSyncTime $ do nodepool <- HashSet.fromList . map snd <$> lift getMempool cachepool <- HashSet.fromList . map snd <$> cacheGetMempool getem (HashSet.difference nodepool cachepool)