haskoin-store 0.52.6 → 0.52.7
raw patch · 3 files changed
+57/−17 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- haskoin-store.cabal +2/−2
- src/Haskoin/Store/Cache.hs +51/−15
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.52.7+### Fixed+- Fix cache bug when too many transactions in mempool.+ ## 0.52.6 ### Changed - Use rationals for Blockchain.info export-history endpoint arithmetics.
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 716fc679461e0323aa97a2801b87331bbf5e45555a85e85a844b5a6f553e61ac+-- hash: 5f0ea1670ea6d31290e445fbdbf155ec7d7383d84e5ba559c87dfb3fbf14266a name: haskoin-store-version: 0.52.6+version: 0.52.7 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
@@ -372,16 +372,16 @@ cacheGetXPubTxs xpub limits = case start limits of Nothing ->- go Nothing+ go1 Nothing Just (AtTx th) -> lift (getTxData th) >>= \case- Just TxData {txDataBlock = b@BlockRef {}} ->- go $ Just (blockRefScore b)- Nothing ->- return []+ Just TxData {txDataBlock = b@BlockRef{}} ->+ go1 $ Just (blockRefScore b)+ _ ->+ go2 th Just (AtBlock h) ->- go (Just (blockRefScore (BlockRef h maxBound)))+ go1 (Just (blockRefScore (BlockRef h maxBound))) where- go score = do+ go1 score = do xs <- runRedis $ getFromSortedSet (txSetPfx <> encode xpub)@@ -390,6 +390,21 @@ (limit limits) touchKeys [xpub] return $ map (uncurry f) xs+ go2 hash = do+ xs <- runRedis $+ getFromSortedSet+ (txSetPfx <> encode xpub)+ Nothing+ 0+ 0+ touchKeys [xpub]+ let xs' = if any ((== hash) . fst) xs+ then dropWhile ((/= hash) . fst) xs+ else []+ return+ $ map (uncurry f)+ $ take (fromIntegral (limit limits))+ $ drop (fromIntegral (offset limits)) xs' f t s = TxRef {txRefHash = t, txRefBlock = scoreBlockRef s} cacheGetXPubUnspents ::@@ -400,16 +415,16 @@ cacheGetXPubUnspents xpub limits = case start limits of Nothing ->- go Nothing+ go1 Nothing Just (AtTx th) -> lift (getTxData th) >>= \case- Just TxData {txDataBlock = b@BlockRef {}} ->- go (Just (blockRefScore b))- Nothing ->- return []+ Just TxData {txDataBlock = b@BlockRef{}} ->+ go1 (Just (blockRefScore b))+ _ ->+ go2 th Just (AtBlock h) ->- go (Just (blockRefScore (BlockRef h maxBound)))+ go1 (Just (blockRefScore (BlockRef h maxBound))) where- go score = do+ go1 score = do xs <- runRedis $ getFromSortedSet@@ -419,6 +434,21 @@ (limit limits) touchKeys [xpub] return $ map (uncurry f) xs+ go2 hash = do+ xs <- runRedis $+ getFromSortedSet+ (utxoPfx <> encode xpub)+ Nothing+ 0+ 0+ touchKeys [xpub]+ let xs' = if any ((== hash) . outPointHash . fst) xs+ then dropWhile ((/= hash) . outPointHash . fst) xs+ else []+ return+ $ map (uncurry f)+ $ take (fromIntegral (limit limits))+ $ drop (fromIntegral (offset limits)) xs' f o s = (scoreBlockRef s, o) redisGetXPubBalances :: (Functor f, RedisCtx m f) => XPubSpec -> m (f [XPubBal])@@ -469,7 +499,13 @@ ys <- map (\(x, s) -> (, s) <$> decode x) <$> xs return (rights ys) getFromSortedSet key (Just score) off 0 = do- xs <- zrangebyscoreWithscoresLimit key score (1 / 0) (fromIntegral off) (-1)+ xs <-+ zrangebyscoreWithscoresLimit+ key+ score+ (1 / 0)+ (fromIntegral off)+ (-1) return $ do ys <- map (\(x, s) -> (, s) <$> decode x) <$> xs return (rights ys)