packages feed

haskoin-store 0.64.10 → 0.64.11

raw patch · 3 files changed

+33/−15 lines, 3 filesdep ~haskoin-store-dataPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: haskoin-store-data

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) +## 0.64.11+### Fixed+- Prune cache more often.+ ## 0.64.10 ### Changed - Return empty addresses in xpub balances call.
haskoin-store.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           haskoin-store-version:        0.64.10+version:        0.64.11 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@@ -60,7 +60,7 @@     , hashable >=1.3.0.0     , haskoin-core >=0.21.1     , haskoin-node >=0.17.0-    , haskoin-store-data ==0.64.10+    , haskoin-store-data ==0.64.11     , hedis >=0.12.13     , http-types >=0.12.3     , lens >=4.18.1@@ -116,7 +116,7 @@     , haskoin-core >=0.21.1     , haskoin-node >=0.17.0     , haskoin-store-    , haskoin-store-data ==0.64.10+    , haskoin-store-data ==0.64.11     , hedis >=0.12.13     , http-types >=0.12.3     , lens >=4.18.1@@ -177,7 +177,7 @@     , haskoin-core >=0.21.1     , haskoin-node >=0.17.0     , haskoin-store-    , haskoin-store-data ==0.64.10+    , haskoin-store-data ==0.64.11     , hedis >=0.12.13     , hspec >=2.7.1     , http-types >=0.12.3
src/Haskoin/Store/Cache.hs view
@@ -812,6 +812,14 @@         withLockRetry (i - 1) f       x -> return x +isFull ::+  (MonadUnliftIO m, MonadLoggerIO m, StoreReadBase m) =>+  CacheX m Bool+isFull = do+  x <- asks cacheMax+  s <- runRedis Redis.dbsize+  return $ s > x+ pruneDB ::   (MonadUnliftIO m, MonadLoggerIO m, StoreReadBase m) =>   CacheX m Integer@@ -823,14 +831,13 @@     flush n =       case n `div` 64 of         0 -> return 0-        x -> fmap (fromMaybe 0) $-          withLock $ do-            ks <--              fmap (map fst) . runRedis $-                getFromSortedSet maxKey Nothing 0 (fromIntegral x)-            $(logDebugS) "Cache" $-              "Pruning " <> cs (show (length ks)) <> " old xpubs"-            delXPubKeys ks+        x -> do+          ks <-+            fmap (map fst) . runRedis $+              getFromSortedSet maxKey Nothing 0 (fromIntegral x)+          $(logDebugS) "Cache" $+            "Pruning " <> cs (show (length ks)) <> " old xpubs"+          delXPubKeys ks  touchKeys :: MonadLoggerIO m => [XPubSpec] -> CacheX m () touchKeys xpubs = do@@ -863,11 +870,12 @@             lift (getTxData txid) >>= mapM_ \tx -> do               $(logDebugS) "Cache" $ "Importing mempool tx: " <> hex               importMultiTxC [tx]+              pruneDB  doSync ::   (MonadUnliftIO m, MonadLoggerIO m, StoreReadExtra m) =>   CacheX m ()-doSync = newBlockC >> void pruneDB+doSync = newBlockC  lenNotNull :: [XPubBal] -> Int lenNotNull = length . filter (not . nullBalance . xPubBal)@@ -908,7 +916,13 @@     op XPubUnspent {xPubUnspent = u} = (unspentPoint u, unspentBlock u)     should_index =       asks cacheMin >>= \x ->-        if x <= lenNotNull xbals then inSync else return False+        if x <= lenNotNull xbals+          then+            inSync >>= \s ->+              if s+                then not <$> isFull+                else return False+          else return False     key = idxPfx <> encode xpub     opts =       Redis.SetOpts@@ -951,7 +965,7 @@               if hb == headerHash (nodeHeader bn)                 then $(logDebugS) "Cache" "Cache in sync"                 else-                  withLock (sync ch hb bn) >>= \case+                  withLock (sync ch hb bn >> void pruneDB) >>= \case                     Nothing -> smallDelay >> newBlockC                     Just () -> return ()   where