haskoin-store 0.45.0 → 0.46.0
raw patch · 5 files changed
+41/−28 lines, 5 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 +8/−0
- haskoin-store.cabal +5/−5
- src/Haskoin/Store/Common.hs +8/−6
- src/Haskoin/Store/Database/Reader.hs +2/−5
- src/Haskoin/Store/Web.hs +18/−12
CHANGELOG.md view
@@ -4,6 +4,14 @@ 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.0+### Fixed+- Release to fix unintentional upload.++## 0.45.0+### Added+- Using a tx_index that results in a txid conflict returns a 409 - Conflict.+ ## 0.44.0 ### Changed - Numeric txid now 53 bits long and doesn't return transactions when hashes collide.
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 32e77f6ea3e02f74893229c350cdad3e1ebfeac9fa713efa9c32cce8c0f9102c+-- hash: dbfd88a5f6129ea2a061932a916de82cd8b764fababef89e549ab5aa0c2caa4f name: haskoin-store-version: 0.45.0+version: 0.46.0 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.44.0+ , haskoin-store-data ==0.45.0 , 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.44.0+ , haskoin-store-data ==0.45.0 , 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.44.0+ , haskoin-store-data ==0.45.0 , hedis >=0.12.13 , hspec >=2.7.1 , http-types >=0.12.3
src/Haskoin/Store/Common.hs view
@@ -35,6 +35,7 @@ import Conduit (ConduitT, dropC, mapC, takeC) import Control.DeepSeq (NFData) import Control.Exception (Exception)+import Control.Monad (forM) import Control.Monad.Trans (lift) import Control.Monad.Trans.Maybe (MaybeT (..), runMaybeT) import Control.Monad.Trans.Reader (runReaderT)@@ -125,7 +126,7 @@ getAddressUnspents :: Address -> Limits -> m [Unspent] getAddressUnspents a = getAddressesUnspents [a] getAddressesUnspents :: [Address] -> Limits -> m [Unspent]- getNumTxData :: Word64 -> m (Maybe TxData)+ getNumTxData :: Word64 -> m [TxData] xPubBals :: XPubSpec -> m [XPubBal] xPubBals xpub = do igap <- getInitialGap@@ -280,11 +281,12 @@ return $ toTransaction d sm getNumTransaction ::- (Monad m, StoreReadExtra m) => Word64 -> m (Maybe Transaction)-getNumTransaction i = runMaybeT $ do- d <- MaybeT $ getNumTxData i- sm <- lift $ getSpenders (txHash (txData d))- return $ toTransaction d sm+ (Monad m, StoreReadExtra m) => Word64 -> m [Transaction]+getNumTransaction i = do+ ds <- getNumTxData i+ forM ds $ \d -> do+ sm <- getSpenders (txHash (txData d))+ return $ toTransaction d sm blockAtOrBefore :: (MonadIO m, StoreReadExtra m) => Chain
src/Haskoin/Store/Database/Reader.hs view
@@ -145,7 +145,7 @@ getTxDataDB th DatabaseReader{databaseHandle = db} = retrieveCF db (txCF db) (TxKey th) -getNumTxDataDB :: MonadIO m => Word64 -> DatabaseReader -> m (Maybe TxData)+getNumTxDataDB :: MonadIO m => Word64 -> DatabaseReader -> m [TxData] getNumTxDataDB i r@DatabaseReader{databaseHandle = db} = do let (sk, w) = decodeTxKey i ls <- liftIO $ matchingAsListCF db (txCF db) (TxKeyS sk)@@ -153,10 +153,7 @@ b = BS.head (BS.drop 6 bs) w' = b .&. 0xf8 in w == w'- xs = filter f $ map snd ls- case xs of- [x] -> return $ Just x- _ -> return Nothing+ return $ filter f $ map snd ls getSpenderDB :: MonadIO m => OutPoint -> DatabaseReader -> m (Maybe Spender) getSpenderDB op DatabaseReader{databaseHandle = db} =
src/Haskoin/Store/Web.hs view
@@ -50,7 +50,8 @@ import Data.List (nub, sortBy) import qualified Data.Map.Strict as Map import Data.Maybe (catMaybes, fromJust, fromMaybe,- listToMaybe, mapMaybe)+ listToMaybe, mapMaybe,+ maybeToList) import Data.Proxy (Proxy (..)) import Data.Serialize as Serialize import qualified Data.Set as Set@@ -87,8 +88,9 @@ import NQE (Inbox, receive, withSubscription) import Network.HTTP.Types (Status (..), status400,- status403, status404, status500,- status503, statusIsClientError,+ status403, status404, status409,+ status500, status503,+ statusIsClientError, statusIsServerError, statusIsSuccessful) import Network.Wai (Middleware, Request (..),@@ -417,12 +419,13 @@ S.raise err errStatus :: Except -> Status-errStatus ThingNotFound = status404-errStatus BadRequest = status400-errStatus UserError{} = status400-errStatus StringError{} = status400-errStatus ServerError = status500-errStatus BlockTooLarge = status403+errStatus ThingNotFound = status404+errStatus BadRequest = status400+errStatus UserError{} = status400+errStatus StringError{} = status400+errStatus ServerError = status500+errStatus BlockTooLarge = status403+errStatus TxIndexConflict{} = status409 defHandler :: Monad m => Except -> WebT m () defHandler e = do@@ -1533,13 +1536,16 @@ setHeaders S.text . TL.fromStrict . encodeHex . encode $ transactionData t go numtxid txid =- let f (BinfoTxIdHash h) = getTransaction h+ let f (BinfoTxIdHash h) = maybeToList <$> getTransaction h f (BinfoTxIdIndex i) = getNumTransaction i in f txid >>= \case- Nothing -> raise rawtxErrors ThingNotFound- Just t -> get_format >>= \case+ [] -> raise rawtxErrors ThingNotFound+ [t] -> get_format >>= \case "hex" -> hex t _ -> js numtxid t+ ts ->+ let tids = map (txHash . transactionData) ts+ in raise rawtxErrors (TxIndexConflict tids) -- GET Network Information --