haskoin-store 0.34.3 → 0.34.4
raw patch · 2 files changed
+24/−17 lines, 2 filesdep ~haskoin-storedep ~haskoin-store-data
Dependency ranges changed: haskoin-store, haskoin-store-data
Files
- haskoin-store.cabal +6/−6
- src/Haskoin/Store/Logic.hs +18/−11
haskoin-store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 043df4dcff9f6f17106efe3b4dba479d97f95d3bdf73257d09b201d42f0b7eb1+-- hash: 94a788ac41a95009b99d7e4662d0189ae04d0c2d2dabe31b2810aae27363d291 name: haskoin-store-version: 0.34.3+version: 0.34.4 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@@ -53,7 +53,7 @@ , hashable >=1.3.0.0 , haskoin-core >=0.13.6 , haskoin-node >=0.14.1- , haskoin-store-data ==0.34.3+ , haskoin-store-data ==0.34.4 , hedis >=0.12.13 , http-types >=0.12.3 , monad-logger >=0.3.32@@ -96,7 +96,7 @@ , haskoin-core >=0.13.6 , haskoin-node >=0.14.1 , haskoin-store- , haskoin-store-data ==0.34.3+ , haskoin-store-data ==0.34.4 , monad-logger >=0.3.32 , mtl >=2.2.2 , nqe >=0.6.1@@ -135,8 +135,8 @@ , hashable >=1.3.0.0 , haskoin-core >=0.13.6 , haskoin-node >=0.14.1- , haskoin-store ==0.34.3- , haskoin-store-data ==0.34.3+ , haskoin-store ==0.34.4+ , haskoin-store-data ==0.34.4 , hedis >=0.12.13 , hspec >=2.7.1 , http-types >=0.12.3
src/Haskoin/Store/Logic.hs view
@@ -54,7 +54,8 @@ TxRef (..), UnixTime, Unspent (..), confirmed) import Haskoin.Store.Database.Writer (MemoryTx, WriterT, runTx)-import UnliftIO (Exception, MonadIO, liftIO)+import UnliftIO (Exception, MonadIO, async,+ liftIO, wait) type MonadImport m = ( MonadError ImportException m@@ -119,23 +120,29 @@ Just _ -> return False Nothing -> do freeOutputs True True [tx]- preLoadMemory [tx]+ preLoadMemory False [tx] rbf <- isRBF (MemRef w) tx checkNewTx tx runMonadMemory $ importTx (MemRef w) w rbf tx return True -preLoadMemory :: MonadLoggerIO m => [Tx] -> WriterT m ()-preLoadMemory txs = do+preLoadMemory :: MonadLoggerIO m => Bool -> [Tx] -> WriterT m ()+preLoadMemory as txs = do $(logDebugS) "BlockStore" "Pre-loading memory" ReaderT $ \r -> do l <- askLoggerIO liftIO (runLoggingT (runReaderT go r) l) where- go = do- mapM_ loadPrevOut (concatMap prevOuts txs)- mapM_ loadOutputBalances txs- runTx . setMempool =<< getMempool+ go+ | as = do+ as1 <- mapM (async . loadPrevOut) (concatMap prevOuts txs)+ as2 <- mapM (async . loadOutputBalances) txs+ runTx . setMempool =<< getMempool+ mapM_ wait $ as1 ++ as2+ | otherwise = do+ mapM_ loadPrevOut (concatMap prevOuts txs)+ mapM_ loadOutputBalances txs+ runTx . setMempool =<< getMempool bestBlockData :: MonadImport m => WriterT m BlockData bestBlockData = do@@ -160,7 +167,7 @@ "Cannot revert non-head block: " <> blockHashToHex bh throwError BlockNotBest tds <- mapM getImportTxData (blockDataTxs bd)- preLoadMemory $ map txData tds+ preLoadMemory True $ map txData tds runTx $ do setBest (prevBlock (blockDataHeader bd)) insertBlock bd {blockDataMainChain = False}@@ -188,7 +195,7 @@ importOrConfirm :: MonadImport m => BlockNode -> [Tx] -> WriterT m () importOrConfirm bn txs = do freeOutputs True False txs- preLoadMemory txs+ preLoadMemory True txs mapM_ (uncurry action) (sortTxs txs) where br i = BlockRef {blockRefHeight = nodeHeight bn, blockRefPos = i}@@ -514,7 +521,7 @@ "Deleting tx: " <> txHashToHex th getSpenders th >>= \case m | I.null m -> do- preLoadMemory [txData td]+ preLoadMemory False [txData td] runTx $ commitDelTx td | otherwise -> do $(logErrorS) "BlockStore" $