haskoin-store-data 0.64.19 → 0.65.0
raw patch · 4 files changed
+28/−17 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Haskoin.Store.Data: [txDataSpenders] :: TxData -> !IntMap Spender
- Haskoin.Store.Data: TxData :: !BlockRef -> !Tx -> !IntMap Prev -> !Bool -> !Bool -> !Word64 -> TxData
+ Haskoin.Store.Data: TxData :: !BlockRef -> !Tx -> !IntMap Prev -> !Bool -> !Bool -> !Word64 -> !IntMap Spender -> TxData
- Haskoin.Store.Data: fromTransaction :: Transaction -> (TxData, IntMap Spender)
+ Haskoin.Store.Data: fromTransaction :: Transaction -> TxData
- Haskoin.Store.Data: toTransaction :: TxData -> IntMap Spender -> Transaction
+ Haskoin.Store.Data: toTransaction :: TxData -> Transaction
Files
- CHANGELOG.md +7/−0
- haskoin-store-data.cabal +2/−2
- src/Haskoin/Store/Data.hs +18/−15
- test/Haskoin/Store/DataSpec.hs +1/−0
CHANGELOG.md view
@@ -4,6 +4,13 @@ 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.65.0+### Changed+- Spenders now embedded into tx objects in database for performance.+- Use faster IORef instead of slow TVar when ingesting.+- Use mutable hash tables when ingesting.+- Allow to disable unscalable API endpoints.+ ## 0.64.19 ### Added - Allow to set query timeouts.
haskoin-store-data.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: a3d81fe29532eb4c3104f251c0fe7500501cd94b8d6fb952c49210aad5eb8c8b+-- hash: 9f15b82cebc6c57573cea5a3666fffba76b706fba860d7999297a78e5668e767 name: haskoin-store-data-version: 0.64.19+version: 0.65.0 synopsis: Data for Haskoin Store description: Please see the README on GitHub at <https://github.com/haskoin/haskoin-store#readme> category: Bitcoin, Finance, Network
src/Haskoin/Store/Data.hs view
@@ -1133,7 +1133,8 @@ txDataPrevs :: !(IntMap Prev), txDataDeleted :: !Bool, txDataRBF :: !Bool,- txDataTime :: !Word64+ txDataTime :: !Word64,+ txDataSpenders :: !(IntMap Spender) } deriving (Show, Eq, Ord, Generic, NFData) @@ -1145,6 +1146,7 @@ serialize txDataDeleted serialize txDataRBF putWord64be txDataTime+ putIntMap (putWord64be . fromIntegral) serialize txDataSpenders deserialize = do txDataBlock <- deserialize txData <- deserialize@@ -1152,6 +1154,7 @@ txDataDeleted <- deserialize txDataRBF <- deserialize txDataTime <- getWord64be+ txDataSpenders <- getIntMap (fromIntegral <$> getWord64be) deserialize return TxData {..} instance Serialize TxData where@@ -1169,8 +1172,8 @@ inputs = sum . map prevAmount $ IntMap.elems txDataPrevs outputs = sum . map outValue $ txOut txData -toTransaction :: TxData -> IntMap Spender -> Transaction-toTransaction t sm =+toTransaction :: TxData -> Transaction+toTransaction t = Transaction { transactionBlock = txDataBlock t, transactionVersion = txVersion (txData t),@@ -1198,21 +1201,21 @@ ws = take (length (txIn (txData t))) $ txWitness (txData t) <> repeat [] f n i = toInput i (IntMap.lookup n (txDataPrevs t)) (ws !! n) ins = zipWith f [0 ..] (txIn (txData t))- g n o = toOutput o (IntMap.lookup n sm)+ g n o = toOutput o (IntMap.lookup n (txDataSpenders t)) outs = zipWith g [0 ..] (txOut (txData t)) -fromTransaction :: Transaction -> (TxData, IntMap Spender)-fromTransaction t = (d, sm)+fromTransaction :: Transaction -> TxData+fromTransaction t =+ TxData+ { txDataBlock = transactionBlock t,+ txData = transactionData t,+ txDataPrevs = ps,+ txDataDeleted = transactionDeleted t,+ txDataRBF = transactionRBF t,+ txDataTime = transactionTime t,+ txDataSpenders = sm+ } where- d =- TxData- { txDataBlock = transactionBlock t,- txData = transactionData t,- txDataPrevs = ps,- txDataDeleted = transactionDeleted t,- txDataRBF = transactionRBF t,- txDataTime = transactionTime t- } f _ StoreCoinbase {} = Nothing f n StoreInput {inputPkScript = s, inputAmount = v} = Just (n, Prev {prevScript = s, prevAmount = v})
test/Haskoin/Store/DataSpec.hs view
@@ -218,6 +218,7 @@ <*> arbitrary <*> arbitrary <*> arbitrary+ <*> arbitrary instance Arbitrary StoreInput where arbitrary =