packages feed

haskoin-store 0.26.4 → 0.26.5

raw patch · 7 files changed

+40/−33 lines, 7 filesdep ~haskoin-store-data

Dependency ranges changed: haskoin-store-data

Files

haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: f31c38533b616fd5c81e849bb14ff8b6c3294bbb3e1c90432b9f6b3e08809ad8+-- hash: 9b01c7b20a2e4262d2e2f1db3f2d12a2d0e32de5b672d89c0c94a00c50f2a80e  name:           haskoin-store-version:        0.26.4+version:        0.26.5 synopsis:       Storage and index for Bitcoin and Bitcoin Cash description:    Store and index Bitcoin or Bitcoin Cash blocks, transactions, balances and unspent outputs.                 All data is available via REST API in JSON or binary format.@@ -57,7 +57,7 @@     , hashable >=1.3.0.0     , haskoin-core >=0.13.3     , haskoin-node >=0.13.0-    , haskoin-store-data ==0.26.4+    , haskoin-store-data ==0.26.5     , hedis >=0.12.13     , http-types >=0.12.3     , monad-logger >=0.3.32@@ -99,7 +99,7 @@     , haskoin-core >=0.13.3     , haskoin-node >=0.13.0     , haskoin-store-    , haskoin-store-data ==0.26.4+    , haskoin-store-data ==0.26.5     , monad-logger >=0.3.32     , mtl >=2.2.2     , nqe >=0.6.1@@ -149,7 +149,7 @@     , hashable >=1.3.0.0     , haskoin-core >=0.13.3     , haskoin-node >=0.13.0-    , haskoin-store-data ==0.26.4+    , haskoin-store-data ==0.26.5     , hedis >=0.12.13     , hspec >=2.7.1     , http-types >=0.12.3
src/Haskoin/Store/Common.hs view
@@ -22,7 +22,7 @@     , applyLimitC     , applyOffsetLimitC     , sortTxs-    , nub+    , nub'     ) where  import           Conduit                   (ConduitT, dropC, mapC, takeC)@@ -169,7 +169,7 @@         bs <- xPubBals xpub         let as = map (balanceAddress . xPubBal) bs         ts <- concat <$> mapM (\a -> getAddressTxs a start limit) as-        let ts' = nub $ sortBy (flip compare `on` blockTxBlock) ts+        let ts' = sortBy (flip compare `on` blockTxBlock) (nub' ts)         return $ applyOffsetLimit offset limit ts'     getMaxGap :: m Word32     getInitialGap :: m Word32@@ -229,7 +229,7 @@ xPubBalsTxs bals start offset limit = do     let as = map balanceAddress . filter (not . nullBalance) $ map xPubBal bals     ts <- concat <$> mapM (\a -> getAddressTxs a start limit) as-    let ts' = nub $ sortBy (flip compare `on` blockTxBlock) ts+    let ts' = sortBy (flip compare `on` blockTxBlock) (nub' ts)     return $ applyOffsetLimit offset limit ts'  getTransaction ::@@ -337,5 +337,5 @@             then go ((i, tx) : orphans) ths xs             else (i, tx) : go orphans (txHash tx `H.delete` ths) xs -nub :: (Eq a, Hashable a) => [a] -> [a]-nub = H.toList . H.fromList+nub' :: (Eq a, Hashable a) => [a] -> [a]+nub' = H.toList . H.fromList
src/Haskoin/Store/Database/Memory.hs view
@@ -19,7 +19,7 @@ import qualified Data.HashMap.Strict          as M import           Data.IntMap.Strict           (IntMap) import qualified Data.IntMap.Strict           as I-import           Data.List                    (nub, sortBy)+import           Data.List                    (sortBy) import           Data.Maybe                   (catMaybes, fromJust, fromMaybe,                                                isJust) import           Data.Word                    (Word32)@@ -28,7 +28,8 @@                                                eitherToMaybe, headerHash,                                                scriptToAddressBS, txHash) import           Haskoin.Store.Common         (Limit, StoreRead (..),-                                               StoreWrite (..), applyLimit)+                                               StoreWrite (..), applyLimit,+                                               nub') import           Haskoin.Store.Data           (Balance (..), BlockData (..),                                                BlockRef, BlockTx (..), Spender,                                                TxData (..), Unspent (..),@@ -114,7 +115,7 @@ getAddressesTxsH addrs start limit db = applyLimit limit xs   where     xs =-        nub . sortBy (flip compare `on` blockTxBlock) . concat $+        sortBy (flip compare `on` blockTxBlock) . nub' . concat $         map (\a -> getAddressTxsH a start limit db) addrs  getAddressTxsH ::@@ -138,7 +139,7 @@ getAddressesUnspentsH addrs start limit db = applyLimit limit xs   where     xs =-        nub . sortBy (flip compare `on` unspentBlock) . concat $+        sortBy (flip compare `on` unspentBlock) . nub' . concat $         map (\a -> getAddressUnspentsH a start limit db) addrs  getAddressUnspentsH ::
src/Haskoin/Store/Database/Reader.hs view
@@ -27,7 +27,7 @@ import           Haskoin                      (Address, BlockHash, BlockHeight,                                                Network, OutPoint (..), TxHash) import           Haskoin.Store.Common         (Limit, StoreRead (..),-                                               applyLimit, applyLimitC, nub)+                                               applyLimit, applyLimitC, nub') import           Haskoin.Store.Data           (Balance, BlockData,                                                BlockRef (..), BlockTx (..),                                                Spender, TxData, Unspent (..),@@ -159,7 +159,7 @@     -> m [BlockTx] getAddressesTxsDB addrs start limit db = do     ts <- concat <$> mapM (\a -> getAddressTxsDB a start limit db) addrs-    let ts' = nub $ sortBy (flip compare `on` blockTxBlock) ts+    let ts' = sortBy (flip compare `on` blockTxBlock) (nub' ts)     return $ applyLimit limit ts'  getAddressTxsDB ::@@ -195,7 +195,7 @@     -> m [Unspent] getAddressesUnspentsDB addrs start limit bdb = do     us <- concat <$> mapM (\a -> getAddressUnspentsDB a start limit bdb) addrs-    let us' = nub $ sortBy (flip compare `on` unspentBlock) us+    let us' = sortBy (flip compare `on` unspentBlock) (nub' us)     return $ applyLimit limit us'  getAddressUnspentsDB ::
src/Haskoin/Store/Database/Writer.hs view
@@ -17,14 +17,14 @@ import qualified Data.HashMap.Strict           as M import           Data.IntMap.Strict            (IntMap) import qualified Data.IntMap.Strict            as I+import           Data.List                     (nub) import           Data.Maybe                    (fromJust, fromMaybe, isJust,                                                 maybeToList) import           Database.RocksDB              (BatchOp) import           Database.RocksDB.Query        (deleteOp, insertOp, writeBatch) import           Haskoin                       (Address, BlockHash, BlockHeight,                                                 OutPoint (..), TxHash)-import           Haskoin.Store.Common          (StoreRead (..), StoreWrite (..),-                                                nub)+import           Haskoin.Store.Common          (StoreRead (..), StoreWrite (..)) import           Haskoin.Store.Data            (Balance, BlockData,                                                 BlockRef (..), BlockTx (..),                                                 Spender, TxData, Unspent,
src/Haskoin/Store/Logic.hs view
@@ -22,7 +22,7 @@ import qualified Data.ByteString.Short   as B.Short import           Data.Either             (rights) import qualified Data.IntMap.Strict      as I-import           Data.List               (sort)+import           Data.List               (sort, nub) import           Data.Maybe              (fromMaybe, isNothing) import           Data.Serialize          (encode) import           Data.String             (fromString)@@ -39,7 +39,7 @@                                           isGenesis, nullOutPoint,                                           scriptToAddressBS, txHash,                                           txHashToHex)-import           Haskoin.Store.Common    (StoreRead (..), StoreWrite (..), nub,+import           Haskoin.Store.Common    (StoreRead (..), StoreWrite (..), nub',                                           sortTxs) import           Haskoin.Store.Data      (Balance (..), BlockData (..),                                           BlockRef (..), BlockTx (..),@@ -134,7 +134,7 @@                             throwError (BlockNotBest (blockHashToHex bh))     txs <- mapM (fmap txData . getImportTxData) (blockDataTxs bd)     ths <--        nub . concat <$>+        nub' . concat <$>         mapM (deleteTx False False . txHash . snd) (reverse (sortTxs txs))     setBest (prevBlock (blockDataHeader bd))     insertBlock bd {blockDataMainChain = False}@@ -177,16 +177,21 @@             , blockDataHeader = nodeHeader n             , blockDataSize = fromIntegral (B.length (encode b))             , blockDataTxs = map txHash (blockTxns b)-            , blockDataWeight = if getSegWit net then fromIntegral w else 0+            , blockDataWeight =+                  if getSegWit net+                      then fromIntegral w+                      else 0             , blockDataSubsidy = subsidy             , blockDataFees = cb_out_val - subsidy             , blockDataOutputs = ts_out_val             }     bs <- getBlocksAtHeight (nodeHeight n)-    setBlocksAtHeight (nub (headerHash (nodeHeader n) : bs)) (nodeHeight n)+    setBlocksAtHeight+        (nub (headerHash (nodeHeader n) : bs))+        (nodeHeight n)     setBest (headerHash (nodeHeader n))     ths <--        nub . concat <$>+        nub' . concat <$>         mapM (uncurry (import_or_confirm mp)) (sortTxs (blockTxns b))     return ths   where@@ -229,7 +234,7 @@     unless (confirmed br) $ do         $(logDebugS) "BlockStore" $             "Importing transaction " <> txHashToHex (txHash tx)-        when (length (nub (map prevOutput (txIn tx))) < length (txIn tx)) $ do+        when (length (nub' (map prevOutput (txIn tx))) < length (txIn tx)) $ do             $(logErrorS) "BlockStore" $                 "Transaction spends same output twice: " <>                 txHashToHex (txHash tx)@@ -244,7 +249,7 @@             then return []             else forM (txIn tx) $ \TxIn {prevOutput = op} -> uns op     let us = map fst us'-        ths = nub (concatMap snd us')+        ths = nub' (concatMap snd us')     when         (not (confirmed br) &&          sum (map unspentAmount us) < sum (map outValue (txOut tx))) $ do@@ -439,7 +444,7 @@     go t = do         $(logWarnS) "BlockStore" $             "Deleting transaction: " <> txHashToHex txhash-        ss <- nub . map spenderHash . I.elems <$> getSpenders txhash+        ss <- nub' . map spenderHash . I.elems <$> getSpenders txhash         ths <-             fmap concat $             forM ss $ \s -> do@@ -455,7 +460,7 @@         unless (confirmed (txDataBlock t)) $ deleteFromMempool txhash         insertTx t {txDataDeleted = True}         updateAddressCounts (txDataAddresses t) (subtract 1)-        return $ nub (txhash : ths)+        return $ nub' (txhash : ths)   isRBF ::@@ -475,7 +480,7 @@         | all (== nullOutPoint) (map prevOutput (txIn tx)) = return False         | any ((< 0xffffffff - 1) . txInSequence) (txIn tx) = return True         | otherwise =-            let hs = nub $ map (outPointHash . prevOutput) (txIn tx)+            let hs = nub' $ map (outPointHash . prevOutput) (txIn tx)                 ck [] = return False                 ck (h:hs') =                     getTxData h >>= \case@@ -770,7 +775,7 @@  txDataAddresses :: TxData -> [Address] txDataAddresses t =-    nub . rights $+    nub' . rights $     map (scriptToAddressBS . prevScript) (I.elems (txDataPrevs t)) <>     map (scriptToAddressBS . scriptOutput) (txOut (txData t)) 
src/Haskoin/Store/Web.hs view
@@ -29,6 +29,7 @@ import qualified Data.ByteString.Lazy.Char8    as C import           Data.Char                     (isSpace) import           Data.Default                  (Default (..))+import           Data.List                     (nub) import           Data.Maybe                    (catMaybes, fromMaybe, isJust,                                                 listToMaybe, mapMaybe) import           Data.Serialize                as Serialize@@ -61,7 +62,7 @@ import           Haskoin.Store.Common          (Limit, Offset, PubExcept (..),                                                 StoreEvent (..), StoreRead (..),                                                 applyOffset, blockAtOrBefore,-                                                getTransaction, nub)+                                                getTransaction, nub') import           Haskoin.Store.Data            (BlockData (..), BlockRef (..),                                                 BlockTx (..), DeriveType (..),                                                 Event (..), Except (..),@@ -1050,7 +1051,7 @@                                  BlockRef {blockRefHeight = b}                                      | b <= h -> return $ Just (e', False)                                  _ ->-                                     r e' . nub $+                                     r e' . nub' $                                      map                                          (outPointHash . inputPoint)                                          (transactionInputs tx)