haskoin-store 0.42.2 → 0.42.3
raw patch · 3 files changed
+36/−18 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/Web.hs +30/−16
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.42.3+### Changed+- Narrow down the balance for transactions to onlyShow set.+ ## 0.42.2 ### Changed - Make unspent algorithm more efficient.
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 435398768b5a020a3d43e48976963d9a5e09109a2db2a74a097b4620f7e2c6ca+-- hash: fd0b9f837b45411e22fa27567a844bb653f099bf3196106e6f113c3af8362bb6 name: haskoin-store-version: 0.42.2+version: 0.42.3 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/Web.hs view
@@ -1310,27 +1310,32 @@ xbals <- get_xbals xspecs let sxbals = subset sxpubs xbals xtrs <- get_xtrs xspecs+ let sxtrs = subset sxpubs xtrs abals <- get_abals addrs- atrs <- get_atrs addrs+ satrs <- get_atrs saddrs+ nosatrs <- get_atrs (addrs `HashSet.difference` saddrs) ticker <- lift $ asks webTicker local <- get_price ticker let xtns = HashMap.map length xtrs- xtrset = Set.fromList . concat $ HashMap.elems xtrs+ xtrset = Set.fromList (concat (HashMap.elems xtrs))+ sxtrset = Set.fromList (concat (HashMap.elems sxtrs)) xabals = compute_xabals xbals sxabals = compute_xabals sxbals sabals = subset saddrs abals sallbals = sabals <> sxabals+ sbal = compute_bal sallbals allbals = abals <> xabals abook = compute_abook addrs xbals sxaddrs = compute_xaddrs sxbals salladdrs = sxaddrs <> saddrs bal = compute_bal allbals- alltrs = xtrset <> atrs- txids = compute_txids alltrs- txs <- get_txs salladdrs (n + offset) txids+ alltrs = xtrset <> nosatrs <> satrs+ salltrs = sxtrset <> satrs+ stxids = compute_txids salltrs+ stxs <- catMaybes <$> mapM getTransaction (take (n + offset) stxids) let etxids = if numtxid- then compute_etxids prune abook (map fst (filter snd txs))+ then compute_etxids prune abook (drop offset stxs) else [] etxs <- if numtxid then Just <$> get_etxs etxids@@ -1338,8 +1343,8 @@ best <- get_best_block peers <- get_peers net <- lift $ asks (storeNetwork . webStore . webConfig)- let ibal = fromIntegral bal- btxs = binfo_txs etxs abook prune ibal txs+ let ibal = fromIntegral sbal+ btxs = binfo_txs etxs salladdrs abook prune ibal stxs ftxs = drop offset btxs baddrs = toBinfoAddrs sabals sxbals xtns abaddrs = toBinfoAddrs abals xbals xtns@@ -1412,15 +1417,24 @@ addr (BinfoXpub x) = Nothing xpub (BinfoXpub x) = Just x xpub (BinfoAddr _) = Nothing- binfo_txs _ _ _ _ [] = []- binfo_txs etxs abook prune ibal ((t, i):ts) =+ compute_bal_change addrs BinfoTx{..} =+ let ins = mapMaybe getBinfoTxInputPrevOut getBinfoTxInputs+ out = getBinfoTxOutputs+ f b BinfoTxOutput{..} =+ let val = fromIntegral getBinfoTxOutputValue+ in case getBinfoTxOutputAddress of+ Nothing -> 0+ Just a | a `HashSet.member` addrs ->+ if b+ then val+ else negate val+ | otherwise -> 0+ in sum $ map (f False) ins <> map (f True) out+ binfo_txs _ _ _ _ _ [] = []+ binfo_txs etxs salladdrs abook prune ibal (t:ts) = let b = toBinfoTx etxs abook prune ibal t- nbal = case getBinfoTxResultBal b of- Nothing -> ibal- Just (_, x) -> ibal - x- in if i- then b : binfo_txs etxs abook prune nbal ts- else binfo_txs etxs abook prune nbal ts+ nbal = ibal - compute_bal_change salladdrs b+ in b : binfo_txs etxs salladdrs abook prune nbal ts get_addrs = do (xspecs, addrs) <- getBinfoActive sh <- getBinfoAddrsParam "onlyShow"