haskoin-store 0.23.1 → 0.23.2
raw patch · 3 files changed
+50/−19 lines, 3 files
Files
- CHANGELOG.md +4/−0
- haskoin-store.cabal +2/−2
- src/Haskoin/Store/Web.hs +44/−17
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.23.2+### Added+- Allow retrieving xpub data without using cache.+ ## 0.23.1 ### Added - Allow xpub eviction from cache via API.
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 9d22c35aa5ef0720ae62cf77e32895f6ef50a8622058d59995ee46d909929821+-- hash: 55f14248c61da3ed48b449cb1caa969fb46f35bb1037cd3b16d3e18b9dbfddc6 name: haskoin-store-version: 0.23.1+version: 0.23.2 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.
src/Haskoin/Store/Web.hs view
@@ -1,11 +1,12 @@-{-# LANGUAGE DeriveAnyClass #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TemplateHaskell #-} module Haskoin.Store.Web ( Except (..) , WebConfig (..)@@ -64,16 +65,16 @@ import Haskoin.Node (Chain, Manager, OnlinePeer (..), chainGetBest, managerGetPeers, sendMessage)-import Haskoin.Store.Cache (CacheT, withCache, delXPubKeys)+import Haskoin.Store.Cache (CacheT, delXPubKeys, withCache) import Haskoin.Store.Common (BlockData (..), BlockRef (..), BlockTx (..), DeriveType (..),- Event (..), HealthCheck (..),- Limit, NetWrap (..), Offset,+ Event (..), GenericResult (..),+ HealthCheck (..), Limit,+ NetWrap (..), Offset, PeerInformation (..), PubExcept (..), StoreEvent (..), StoreInput (..), StoreRead (..),- Transaction (..),- GenericResult (..), TxData (..),+ Transaction (..), TxData (..), TxId (..), UnixTime, Unspent, XPubBal (..), XPubSpec (..), applyOffset, blockAtOrBefore,@@ -218,6 +219,11 @@ Nothing -> bf Just c -> withCache c cf +runNoCache :: MonadIO m => DatabaseReaderT m a -> WebT m a+runNoCache f = lift $ do+ bdb <- asks (storeDB . webStore)+ lift $ withDatabaseReader bdb f+ instance MonadLoggerIO m => StoreRead (ReaderT WebConfig m) where getMaxGap = runInWebReader getMaxGap getMaxGap getInitialGap = runInWebReader getInitialGap getInitialGap@@ -597,14 +603,20 @@ scottyXpubBalances :: MonadLoggerIO m => WebT m () scottyXpubBalances = do setHeaders+ nocache <- parseNoCache xpub <- parseXpub proto <- setupBin- res <- filter (not . nullBalance . xPubBal) <$> xPubBals xpub+ res <-+ filter (not . nullBalance . xPubBal) <$>+ if nocache+ then runNoCache (xPubBals xpub)+ else xPubBals xpub protoSerialNet proto res scottyXpubTxs :: MonadLoggerIO m => Bool -> WebT m () scottyXpubTxs full = do setHeaders+ nocache <- parseNoCache xpub <- parseXpub start <- getStart limit <- getLimit full@@ -612,7 +624,11 @@ txs <- xPubTxs xpub start 0 limit if full then do- txs' <- catMaybes <$> mapM (getTransaction . blockTxHash) txs+ txs' <-+ catMaybes <$>+ if nocache+ then runNoCache (mapM (getTransaction . blockTxHash) txs)+ else mapM (getTransaction . blockTxHash) txs protoSerialNet proto txs' else protoSerial proto txs @@ -631,19 +647,27 @@ scottyXpubUnspents :: MonadLoggerIO m => WebT m () scottyXpubUnspents = do setHeaders+ nocache <- parseNoCache xpub <- parseXpub proto <- setupBin start <- getStart limit <- getLimit False- uns <- xPubUnspents xpub start 0 limit+ uns <-+ if nocache+ then runNoCache (xPubUnspents xpub start 0 limit)+ else xPubUnspents xpub start 0 limit protoSerial proto uns scottyXpubSummary :: MonadLoggerIO m => WebT m () scottyXpubSummary = do setHeaders+ nocache <- parseNoCache xpub <- parseXpub proto <- setupBin- res <- xPubSummary xpub+ res <-+ if nocache+ then runNoCache (xPubSummary xpub)+ else xPubSummary xpub protoSerial proto res scottyPostTx ::@@ -884,6 +908,9 @@ "compat" -> DeriveP2SH _ -> DeriveNormal | otherwise -> return DeriveNormal++parseNoCache :: (Monad m, ScottyError e) => ActionT e m Bool+parseNoCache = S.param "nocache" `S.rescue` const (return False) parseNoTx :: (Monad m, ScottyError e) => ActionT e m Bool parseNoTx = S.param "notx" `S.rescue` const (return False)