summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxenog <>2019-03-14 09:51:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-03-14 09:51:00 (GMT)
commitaf2157f64a8464322b3630fe1021d47dcafbfb9a (patch)
tree3cc203f33fc88785d304f6a76df3d01b749914a3
parent10906838fc0de9e8a2b98d36c733c92ae11452d6 (diff)
version 0.11.20.11.2
-rw-r--r--CHANGELOG.md4
-rw-r--r--haskoin-store.cabal4
-rw-r--r--src/Haskoin/Store.hs4
-rw-r--r--src/Network/Haskoin/Store/Block.hs3
-rw-r--r--src/Network/Haskoin/Store/Logic.hs13
5 files changed, 18 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5126610..5327a1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
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.11.2
+### Changed
+- Fix duplicate mempool transaction announcements in event stream.
+
## 0.11.1
### Removed
- Removed latest block time check.
diff --git a/haskoin-store.cabal b/haskoin-store.cabal
index a1c479f..433cb13 100644
--- a/haskoin-store.cabal
+++ b/haskoin-store.cabal
@@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
--- hash: 139f91772d993146024af96c5aaf5d871181cb34df80da213de5de2bd4ebfe99
+-- hash: fb34b3d0d4ea2f11f65e907766f8a85bb16500b28c01fef91a8e4cc677a558bb
name: haskoin-store
-version: 0.11.1
+version: 0.11.2
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
diff --git a/src/Haskoin/Store.hs b/src/Haskoin/Store.hs
index d738c0c..af29f3b 100644
--- a/src/Haskoin/Store.hs
+++ b/src/Haskoin/Store.hs
@@ -78,7 +78,6 @@ import Data.Function
import Data.List
import Data.Maybe
import Data.Serialize (decode)
-import Data.Time.Clock.System
import Database.RocksDB as R
import Haskoin
import Haskoin.Node
@@ -234,8 +233,7 @@ healthCheck net i mgr ch = do
MaybeT $ getBlock i h
p <- timeout (5 * 1000 * 1000) $ managerGetPeers mgr
let k = isNothing n || isNothing b || maybe False (not . null) p
- t <- fromIntegral . systemSeconds <$> liftIO getSystemTime
- let s =
+ s =
isJust $ do
x <- n
y <- b
diff --git a/src/Network/Haskoin/Store/Block.hs b/src/Network/Haskoin/Store/Block.hs
index 53525a7..82ee550 100644
--- a/src/Network/Haskoin/Store/Block.hs
+++ b/src/Network/Haskoin/Store/Block.hs
@@ -215,9 +215,10 @@ processTx _p tx =
$(logErrorS) "Block" $
"Error importing tx: " <> txHashToHex (txHash tx) <> ": " <>
fromString (show e)
- Right () -> do
+ Right True -> do
l <- blockConfListener <$> asks myConfig
atomically $ l (StoreMempoolNew (txHash tx))
+ Right False -> return ()
processTxs ::
(MonadReader BlockRead m, MonadUnliftIO m, MonadLoggerIO m)
diff --git a/src/Network/Haskoin/Store/Logic.hs b/src/Network/Haskoin/Store/Logic.hs
index 3d26298..5102a7c 100644
--- a/src/Network/Haskoin/Store/Logic.hs
+++ b/src/Network/Haskoin/Store/Logic.hs
@@ -89,7 +89,7 @@ newMempoolTx ::
-> i
-> Tx
-> PreciseUnixTime
- -> m ()
+ -> m Bool
newMempoolTx net i tx now@(PreciseUnixTime w) = do
$(logInfoS) "BlockLogic" $
"Adding transaction to mempool: " <> txHashToHex (txHash tx)
@@ -98,7 +98,7 @@ newMempoolTx net i tx now@(PreciseUnixTime w) = do
| not (txDataDeleted x) -> do
$(logWarnS) "BlockLogic" $
"Transaction already exists: " <> txHashToHex (txHash tx)
- return ()
+ return False
_ -> go
where
go = do
@@ -107,7 +107,8 @@ newMempoolTx net i tx now@(PreciseUnixTime w) = do
mapM (getTxData i . outPointHash . prevOutput) (txIn tx)
if orp
then do
- $(logErrorS) "BlockLogic" $ "Transaction is orphan: " <> txHashToHex (txHash tx)
+ $(logErrorS) "BlockLogic" $
+ "Transaction is orphan: " <> txHashToHex (txHash tx)
throwError $ OrphanTx (txHash tx)
else f
f = do
@@ -117,7 +118,9 @@ newMempoolTx net i tx now@(PreciseUnixTime w) = do
getTxOutput (outPointIndex op) t
let ds = map spenderHash (mapMaybe outputSpender us)
if null ds
- then importTx net i (MemRef now) (w `div` 1000) tx
+ then do
+ importTx net i (MemRef now) (w `div` 1000) tx
+ return True
else g ds
g ds = do
$(logWarnS) "BlockLogic" $
@@ -134,11 +137,13 @@ newMempoolTx net i tx now@(PreciseUnixTime w) = do
"Replacting RBF transaction with: " <> txHashToHex (txHash tx)
forM_ ds (deleteTx net i True)
importTx net i (MemRef now) (w `div` 1000) tx
+ return True
n = do
$(logWarnS) "BlockLogic" $
"Inserting transaction with deleted flag: " <>
txHashToHex (txHash tx)
insertDeletedMempoolTx i tx now
+ return False
isrbf th = transactionRBF <$> getImportTx i th
newBlock ::