haskoin-store 1.5.11 → 1.5.12
raw patch · 3 files changed
+28/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- haskoin-store.cabal +1/−1
- src/Haskoin/Store/BlockStore.hs +22/−4
- src/Haskoin/Store/Web.hs +5/−1
haskoin-store.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: haskoin-store-version: 1.5.11+version: 1.5.12 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/BlockStore.hs view
@@ -93,7 +93,8 @@ getCurrentTime, ) import Data.Time.Clock.POSIX- ( posixSecondsToUTCTime,+ ( getPOSIXTime,+ posixSecondsToUTCTime, utcTimeToPOSIXSeconds, ) import Data.Time.Format@@ -232,7 +233,8 @@ headers :: !StatGauge, queuedTxs :: !StatGauge, peers :: !StatGauge,- mempool :: !StatGauge+ mempool :: !StatGauge,+ block :: !StatTiming } newStoreMetrics :: (MonadIO m) => BlockStoreConfig -> m (Maybe StoreMetrics)@@ -251,9 +253,11 @@ queuedTxs <- g s "queued_txs" 0 peers <- g s "peers" (length p) mempool <- g s "mempool" (length m)+ block <- t s "block" 0 return StoreMetrics {..} where g s x = newStatGauge s ("store." <> x)+ t s x = newStatTiming s ("store." <> x) setStoreHeight :: (MonadIO m) => BlockT m () setStoreHeight = void $ runMaybeT $ do@@ -286,6 +290,19 @@ p <- lift getMempool setGauge m.mempool (length p) +withBlockTiming :: (MonadIO m) => BlockT m (Either l r) -> BlockT m (Either l r)+withBlockTiming go = do+ asks (.metrics) >>= \case+ Just m -> do+ start <- round . (* 1000) <$> liftIO getPOSIXTime+ go >>= \case+ Right x -> do+ end <- round . (* 1000) <$> liftIO getPOSIXTime+ addTiming m.block (end - start)+ return (Right x)+ Left y -> return (Left y)+ Nothing -> go+ -- | Configuration for a block store. data BlockStoreConfig = BlockStoreConfig { ctx :: !Ctx,@@ -511,8 +528,9 @@ <> peer.label net <- lift getNetwork ctx <- lift getCtx- lift . notify (Just block) $- runImport net ctx (importBlock block node) >>= \case+ lift . notify (Just block) $ do+ ret <- withBlockTiming $ runImport net ctx (importBlock block node)+ case ret of Left e -> failure e Right _ -> success node where
src/Haskoin/Store/Web.hs view
@@ -1873,7 +1873,11 @@ getBlock bh >>= \case Nothing -> raise ThingNotFound Just b -> return b- get_prune = fmap not $ param "noCompact" `rescue` return False+ get_prune =+ fmap not $+ param "noCompact"+ `rescue` param "no_compact"+ `rescue` return False only_show_xbals sxpubs = HashMap.filterWithKey (\k _ -> k.key `HashSet.member` sxpubs) only_show_xspecs sxpubs =