packages feed

haskoin-store 0.46.0 → 0.46.1

raw patch · 3 files changed

+40/−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.46.1+### Added+- Filters for transactions in multiaddr endpoint.+ ## 0.46.0 ### Fixed - Release to fix unintentional upload.
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: dbfd88a5f6129ea2a061932a916de82cd8b764fababef89e549ab5aa0c2caa4f+-- hash: 54e063421a212c7cc9c4ea83a87047a50236607b6a33ce75b10eb9a593bd49bd  name:           haskoin-store-version:        0.46.0+version:        0.46.1 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@@ -59,7 +59,7 @@     , hashable >=1.3.0.0     , haskoin-core >=0.19.0     , haskoin-node >=0.17.0-    , haskoin-store-data ==0.45.0+    , haskoin-store-data ==0.46.1     , hedis >=0.12.13     , http-types >=0.12.3     , lens >=4.18.1@@ -109,7 +109,7 @@     , haskoin-core >=0.19.0     , haskoin-node >=0.17.0     , haskoin-store-    , haskoin-store-data ==0.45.0+    , haskoin-store-data ==0.46.1     , hedis >=0.12.13     , http-types >=0.12.3     , lens >=4.18.1@@ -164,7 +164,7 @@     , haskoin-core >=0.19.0     , haskoin-node >=0.17.0     , haskoin-store-    , haskoin-store-data ==0.45.0+    , haskoin-store-data ==0.46.1     , hedis >=0.12.13     , hspec >=2.7.1     , http-types >=0.12.3
src/Haskoin/Store/Web.hs view
@@ -50,7 +50,7 @@ import           Data.List                     (nub, sortBy) import qualified Data.Map.Strict               as Map import           Data.Maybe                    (catMaybes, fromJust, fromMaybe,-                                                listToMaybe, mapMaybe,+                                                isJust, listToMaybe, mapMaybe,                                                 maybeToList) import           Data.Proxy                    (Proxy (..)) import           Data.Serialize                as Serialize@@ -1314,6 +1314,7 @@     get_offset >>= \offset ->     get_count >>= \n ->     get_prune >>= \prune ->+    get_filter >>= \fltr ->     let len = HashSet.size addrs + HashSet.size xpubs     in withMetrics multiaddrResponseTime len $ do     xbals <- get_xbals xspecs@@ -1339,13 +1340,12 @@         alltrs = xtrset <> nosatrs <> satrs         salltrs = sxtrset <> satrs         stxids = compute_txids salltrs-    stxs <- catMaybes <$> mapM getTransaction (take (n + offset) stxids)+    let ibal = fromIntegral sbal+    btxs <- binfo_txs (n + offset) fltr numtxid salladdrs abook prune ibal stxids     best <- get_best_block     peers <- get_peers     net <- lift $ asks (storeNetwork . webStore . webConfig)-    let ibal = fromIntegral sbal-        btxs = binfo_txs numtxid salladdrs abook prune ibal stxs-        ftxs = drop offset btxs+    let ftxs = drop offset btxs         baddrs = toBinfoAddrs sabals sxbals xtns         abaddrs = toBinfoAddrs abals xbals xtns         recv = sum $ map getBinfoAddrReceived abaddrs@@ -1386,6 +1386,7 @@         , getBinfoMultiAddrCashAddr = cashaddr         }   where+    get_filter = S.param "filter" `S.rescue` const (return BinfoFilterAll)     get_best_block =         getBestBlock >>= \case         Nothing -> raise multiaddrErrors ThingNotFound@@ -1430,11 +1431,31 @@                                 else negate val                               | otherwise -> 0         in sum $ map (f False) ins <> map (f True) out-    binfo_txs _ _ _ _ _ [] = []-    binfo_txs numtxid salladdrs abook prune ibal (t:ts) =-        let b = toBinfoTx numtxid abook prune ibal t-            nbal = ibal - compute_bal_change salladdrs b-         in b : binfo_txs numtxid salladdrs abook prune nbal ts+    binfo_txs _ _ _ _ _ _ _ [] = return []+    binfo_txs 0 _ _ _ _ _ _ _ = return []+    binfo_txs i f n s o p b (t:ts) =+        getTransaction t >>= \case+        Nothing -> binfo_txs i f n s o p b ts+        Just x -> do+            let a = toBinfoTx n o p b x+                b' = b - compute_bal_change s a+                c = isJust (getBinfoTxBlockHeight a)+                Just (d, _) = getBinfoTxResultBal a+                r = d + fromIntegral (getBinfoTxFee a)+                y = (a:) <$> binfo_txs (i-1) f n s o p b' ts+                z = binfo_txs i f n s o p b' ts+            case f of+                BinfoFilterAll -> y+                BinfoFilterSent ->+                    if r < 0 then y else z+                BinfoFilterReceived ->+                    if r > 0 then y else z+                BinfoFilterMoved ->+                    if r == 0 then y else z+                BinfoFilterConfirmed ->+                    if c then y else z+                BinfoFilterMempool ->+                    if not c then y else return []     get_addrs = do         (xspecs, addrs) <- getBinfoActive multiaddrErrors         sh <- getBinfoAddrsParam multiaddrErrors "onlyShow"