packages feed

haskoin-store 0.6.7 → 0.6.8

raw patch · 4 files changed

+24/−15 lines, 4 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.6.8+### Changed+- Further optimize coinbase after height checks.+ ## 0.6.7 ### Changed - Impose restrictions on recursion for coinbase after height checks.
app/Main.hs view
@@ -289,7 +289,7 @@             res <-                 withSnapshot db $ \s -> do                 let d = (db, defaultReadOptions {useSnapshot = Just s})-                cbAfterHeight d 100 height txid+                cbAfterHeight d 100000 height txid             S.json $ object ["result" .= res]         S.get "/transactions" $ do             txids <- param "txids"
haskoin-store.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: db673c6b1202a70890532986a1332d88c3463356e623cf7e03853a905961700b+-- hash: ccd67ad2ad06941bbac623fbc3d7133ab14bc89b0ea120648557071e3501d0d4  name:           haskoin-store-version:        0.6.7+version:        0.6.8 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
@@ -277,21 +277,26 @@     -> TxHash     -> m (Maybe Bool) cbAfterHeight _ 0 _ _ = return Nothing-cbAfterHeight i d h t =-    runMaybeT $ do-        tx <- MaybeT $ getTransaction i t+cbAfterHeight i d h t = runMaybeT $ snd <$> tst d t+  where+    tst 0 _ = MaybeT $ return Nothing+    tst e x = do+        let e' = e - 1+        tx <- MaybeT $ getTransaction i x         if any isCoinbase (transactionInputs tx)-            then return $ blockRefHeight (transactionBlock tx) > h+            then return (e', blockRefHeight (transactionBlock tx) > h)             else case transactionBlock tx of                      BlockRef {blockRefHeight = b}-                         | b <= h -> return False-                     _ -> do-                         let ins =-                                 nub $-                                 map-                                     (outPointHash . inputPoint)-                                     (transactionInputs tx)-                         or <$> mapM (MaybeT . cbAfterHeight i (d - 1) h) ins+                         | b <= h -> return (e', False)+                     _ ->+                         r e' . nub $+                         map (outPointHash . inputPoint) (transactionInputs tx)+    r e [] = return (e, False)+    r e (n:ns) = do+        (e', s) <- tst e n+        if s+            then return (e', True)+            else r e' ns  -- Snatched from: -- https://github.com/cblp/conduit-merge/blob/master/src/Data/Conduit/Merge.hs