packages feed

haskoin-store 0.21.4 → 0.21.5

raw patch · 6 files changed

+28/−5 lines, 6 files

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.21.5+### Added+- Only store xpubs in cache if they have more than a threshold addresses used.+ ## 0.21.4 ### Fixed - Fix shared cache case where head is set beyond header chain by another node.
app/Main.hs view
@@ -52,6 +52,7 @@     , configTimeouts  :: !Timeouts     , configRedis     :: !Bool     , configRedisURL  :: !String+    , configRedisMin  :: !Int     }  defPort :: Int@@ -76,6 +77,9 @@ defTimeouts :: Timeouts defTimeouts = Timeouts {blockTimeout = 7200, txTimeout = 600} +defRedisMin :: Int+defRedisMin = 100+ config :: Parser Config config = do     configDir <-@@ -148,6 +152,12 @@     configRedisURL <-         strOption $         metavar "URL" <> long "redis" <> help "URL for Redis cache" <> value ""+    configRedisMin <-+        option auto $+        metavar "MINADDRS" <> long "cachemin" <>+        help "Minmum xpub address count to cache" <>+        showDefault <>+        value defRedisMin     pure         Config             { configMaxLimits = MaxLimits {..}@@ -211,6 +221,7 @@            , configTimeouts = tos            , configRedis = redis            , configRedisURL = redisurl+           , configRedisMin = cachemin            } =     runStderrLoggingT . filterLogger l $ do         $(logInfoS) "Main" $@@ -232,6 +243,7 @@                             , storeConfPublisher = pub                             , storeConfCache = maybecache                             , storeConfGap = maxLimitGap limits+                            , storeConfCacheMin = cachemin                             }                  in withStore scfg $ \st ->                         let crcfg =@@ -267,7 +279,7 @@                     if null redisurl                         then return defaultConnectInfo                         else case parseConnectInfo redisurl of-                                 Left e -> error e+                                 Left e  -> error e                                  Right r -> return r                 cachembox <- newInbox                 withRunInIO $ \r ->
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 5d2420570a90418f4e6d3bacfad7ad4322d1f833803722530d53417acf035e02+-- hash: 9bff1adfaf74aaf3153599679243ab87120bbe1bbd3480d7ce1545f66a3c50f8  name:           haskoin-store-version:        0.21.4+version:        0.21.5 synopsis:       Storage and index for Bitcoin and Bitcoin Cash description:    Store blocks, transactions, and balances for Bitcoin or Bitcoin Cash, and make that information via REST API. category:       Bitcoin, Finance, Network
src/Haskoin/Store.hs view
@@ -76,6 +76,8 @@       -- ^ Redis cache configuration         , storeConfGap       :: !Word32       -- ^ gap for extended public keys+        , storeConfCacheMin  :: !Int+      -- ^ minimum number of addresses for caching         }  withStore ::@@ -143,6 +145,7 @@                             , cacheWriterChain = c                             , cacheWriterMailbox = snd cacheinfo                             , cacheWriterNetwork = storeConfNetwork cfg+                            , cacheWriterMin = storeConfCacheMin cfg                             }                     cw =                         withDatabaseReader
src/Network/Haskoin/Store/CacheWriter.hs view
@@ -53,7 +53,7 @@                                                          XPubBal (..),                                                          XPubSpec (..),                                                          XPubUnspent (..),-                                                         sortTxs,+                                                         nullBalance, sortTxs,                                                          xPubAddrFunction,                                                          xPubBals, xPubTxs,                                                          xPubUnspents)@@ -80,6 +80,7 @@         , cacheWriterChain   :: !Chain         , cacheWriterMailbox :: !CacheWriterInbox         , cacheWriterNetwork :: !Network+        , cacheWriterMin     :: !Int         }  type CacheWriterT = ReaderT CacheWriterConfig@@ -143,9 +144,11 @@     -> CacheWriterT m () newXPubC xpub = do     empty <- null <$> runCacheReaderT (cacheGetXPubBalances xpub)+    x <- asks cacheWriterMin     when empty $ do         bals <- lift $ xPubBals xpub-        go bals+        let l = length (filter (not . nullBalance . xPubBal) bals)+        when (x <= l) (go bals)   where     go bals = do         utxo <- lift $ xPubUnspents xpub Nothing 0 Nothing
test/Haskoin/StoreSpec.hs view
@@ -98,6 +98,7 @@                         , storeConfPublisher = pub                         , storeConfCache = Nothing                         , storeConfGap = gap+                        , storeConfCacheMin = 100                         }             withStore cfg $ \Store {..} -> withSubscription pub $ \sub ->                 lift $