haskoin-store 0.9.0 → 0.9.1
raw patch · 7 files changed
+34/−8 lines, 7 files
Files
- CHANGELOG.md +10/−0
- app/Main.hs +2/−0
- haskoin-store.cabal +2/−2
- src/Haskoin/Store.hs +1/−1
- src/Network/Haskoin/Store/Data.hs +10/−2
- src/Network/Haskoin/Store/Data/RocksDB.hs +1/−1
- src/Network/Haskoin/Store/Logic.hs +8/−2
CHANGELOG.md view
@@ -4,6 +4,16 @@ 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.1+### Added+- Total block fees.+- Total block outputs.+- Block subsidy.++### Changed+- Do not consider the blocks less one block away from headers as out of sync in health check.+- Health check now returns HTTP 503 when not OK or out of sync.+ ## 0.9.0 ### Added - Version to health check output.
app/Main.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE ApplicativeDo #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}@@ -510,6 +511,7 @@ (db, defaultReadOptions) (storeManager st) (storeChain st)+ when (not (healthOK h) || not (healthSynced h)) $ status status503 S.json h notFound $ raise ThingNotFound where
haskoin-store.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 6ac575f0a235a7af3c995ba075ee5e8a91f0f70327fe186361fe1da63393e81c+-- hash: f7f6a1e100b553cf8e1d3d6efecbfba20f1d30e559140218fec71f61d17d55df name: haskoin-store-version: 0.9.0+version: 0.9.1 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
src/Haskoin/Store.hs view
@@ -203,7 +203,7 @@ isJust $ do x <- n y <- b- guard $ nodeHeader x == blockDataHeader y+ guard $ nodeHeight x - blockDataHeight y <= 1 guard $ blockTimestamp (blockDataHeader y) >= t - 7200 return HealthCheck
src/Network/Haskoin/Store/Data.hs view
@@ -269,6 +269,12 @@ -- ^ weight of this block (for segwit networks) , blockDataTxs :: ![TxHash] -- ^ block transactions+ , blockDataOutputs :: !Word64+ -- ^ sum of all transaction outputs+ , blockDataFees :: !Word64+ -- ^ sum of all transaction fees+ , blockDataSubsidy :: !Word64+ -- ^ block subsidy } deriving (Show, Read, Eq, Ord, Generic, Serialize, Hashable) -- | JSON serialization for 'BlockData'.@@ -285,6 +291,9 @@ , "size" .= blockDataSize bv , "tx" .= blockDataTxs bv , "merkle" .= TxHash (merkleRoot (blockDataHeader bv))+ , "subsidy" .= blockDataSubsidy bv+ , "fees" .= blockDataFees bv+ , "outputs" .= blockDataOutputs bv ] ++ ["weight" .= blockDataWeight bv | getSegWit net] blockDataToJSON :: Network -> BlockData -> Value@@ -553,8 +562,7 @@ where w = let b = B.length $ S.encode (transactionData dtx) {txWitness = []} x = B.length $ S.encode (transactionData dtx)- d = x - b- in b * 4 + d+ in b * 3 + x transactionToJSON :: Network -> Transaction -> Value transactionToJSON net = object . transactionPairs net
src/Network/Haskoin/Store/Data/RocksDB.hs view
@@ -19,7 +19,7 @@ import UnliftIO dataVersion :: Word32-dataVersion = 13+dataVersion = 14 data ExceptRocksDB = MempoolTxNotFound
src/Network/Haskoin/Store/Logic.hs view
@@ -21,6 +21,7 @@ import Data.Word import Database.RocksDB import Haskoin+import Network.Haskoin.Block.Headers (computeSubsidy) import Network.Haskoin.Store.Data import Network.Haskoin.Store.Data.HashMap import Network.Haskoin.Store.Data.ImportDB@@ -234,6 +235,9 @@ , blockDataSize = fromIntegral (B.length (encode b)) , blockDataTxs = map txHash (blockTxns b) , blockDataWeight = fromIntegral w+ , blockDataSubsidy = subsidy (nodeHeight n)+ , blockDataFees = cb_out_val - subsidy (nodeHeight n)+ , blockDataOutputs = ts_out_val } insertAtHeight i (headerHash (nodeHeader n)) (nodeHeight n) setBest i (headerHash (nodeHeader n))@@ -248,11 +252,13 @@ [0 ..] (sortTxs (blockTxns b)) where+ subsidy = computeSubsidy net+ cb_out_val = sum (map outValue (txOut (head (blockTxns b))))+ ts_out_val = sum (map (\tx -> sum (map outValue (txOut tx))) (tail (blockTxns b))) br pos = BlockRef {blockRefHeight = nodeHeight n, blockRefPos = pos} w = let s = B.length (encode b {blockTxns = map (\t -> t {txWitness = []}) (blockTxns b)}) x = B.length (encode b)- d = x - s- in s * 4 + d+ in s * 3 + x sortTxs :: [Tx] -> [Tx] sortTxs [] = []