haskoin-store 0.9.1 → 0.9.2
raw patch · 3 files changed
+56/−15 lines, 3 files
Files
- CHANGELOG.md +4/−0
- app/Main.hs +50/−13
- haskoin-store.cabal +2/−2
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.9.2+### Added+- HTTP JSON API switch to turn off transaction list when retrieving blocks.+ ## 0.9.1 ### Added - Total block fees.
app/Main.hs view
@@ -219,48 +219,84 @@ scottyT (configPort conf) (runner l) $ do defaultHandler defHandler S.get "/block/best" $ do+ n <- parse_no_tx res <- withSnapshot db $ \s -> runMaybeT $ do let d = (db, defaultReadOptions {useSnapshot = Just s}) bh <- MaybeT $ getBestBlock d- MaybeT $ getBlock d bh+ b <- MaybeT $ getBlock d bh+ if n+ then return+ b {blockDataTxs = take 1 (blockDataTxs b)}+ else return b maybeJSON (blockDataToJSON net <$> res) S.get "/block/:block" $ do block <- param "block"+ n <- parse_no_tx res <-- withSnapshot db $ \s -> do- let d = (db, defaultReadOptions {useSnapshot = Just s})- getBlock d block+ withSnapshot db $ \s ->+ runMaybeT $ do+ let d = (db, defaultReadOptions {useSnapshot = Just s})+ b <- MaybeT $ getBlock d block+ if n+ then return+ b {blockDataTxs = take 1 (blockDataTxs b)}+ else return b maybeJSON (blockDataToJSON net <$> res) S.get "/block/height/:height" $ do height <- param "height"+ n <- parse_no_tx res <- withSnapshot db $ \s -> do let d = (db, defaultReadOptions {useSnapshot = Just s}) bs <- getBlocksAtHeight d height- catMaybes <$>- mapM (fmap (fmap (blockDataToJSON net)) . getBlock d) bs+ fmap catMaybes . forM bs $ \bh ->+ runMaybeT $ do+ b <- MaybeT $ getBlock d bh+ return . blockDataToJSON net $+ if n+ then b+ { blockDataTxs =+ take 1 (blockDataTxs b)+ }+ else b S.json res S.get "/block/heights" $ do heights <- param "heights"+ n <- parse_no_tx res <- withSnapshot db $ \s -> do let d = (db, defaultReadOptions {useSnapshot = Just s}) bs <- mapM (getBlocksAtHeight d) (nub heights)- mapM- (fmap catMaybes .- mapM (fmap (fmap (blockDataToJSON net)) . getBlock d))- bs+ forM bs $ \hs ->+ fmap catMaybes . forM hs $ \bh ->+ runMaybeT $ do+ b <- MaybeT $ getBlock d bh+ return . blockDataToJSON net $+ if n+ then b+ { blockDataTxs =+ take 1 (blockDataTxs b)+ }+ else b S.json res S.get "/blocks" $ do blocks <- param "blocks"+ n <- parse_no_tx res <- withSnapshot db $ \s -> do let d = (db, defaultReadOptions {useSnapshot = Just s})- mapM- (fmap (fmap (blockDataToJSON net)) . getBlock d)- (blocks :: [BlockHash])+ fmap catMaybes . forM blocks $ \bh ->+ runMaybeT $ do+ b <- MaybeT $ getBlock d bh+ return . blockDataToJSON net $+ if n+ then b+ { blockDataTxs =+ take 1 (blockDataTxs b)+ }+ else b S.json res S.get "/mempool" $ do setHeader "Content-Type" "application/json"@@ -548,6 +584,7 @@ Nothing -> next Just x -> return x net = configNetwork conf+ parse_no_tx = param "notx" `rescue` const (return False) runner f l = do u <- askUnliftIO unliftIO u (runLoggingT l f)
haskoin-store.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: f7f6a1e100b553cf8e1d3d6efecbfba20f1d30e559140218fec71f61d17d55df+-- hash: b1b27b7b730c1f74df14f57fce33ac9a10a7a7aaf2ed921525fa359d3ac90618 name: haskoin-store-version: 0.9.1+version: 0.9.2 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