summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxenog <>2018-10-18 21:10:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-10-18 21:10:00 (GMT)
commit59c6d86531e32bf8f8dd5fbaef698e7d02dc5259 (patch)
tree8376c6f8e34244bcd842eab33a048c6cdf5adc14
parent34333cee1b331e879a0717be34a83dba369381a6 (diff)
version 0.9.20.9.2
-rw-r--r--CHANGELOG.md4
-rw-r--r--haskoin-node.cabal4
-rw-r--r--src/Network/Haskoin/Node/Peer.hs12
3 files changed, 11 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d5edc6..c175056 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.9.2
+### Change
+- Peer dies immediately when receiving a bad message.
+
## 0.9.1
### Changed
- Keep track of last synced header from a peer to avoid endless loops on large reorgs.
diff --git a/haskoin-node.cabal b/haskoin-node.cabal
index d447a09..42e57ef 100644
--- a/haskoin-node.cabal
+++ b/haskoin-node.cabal
@@ -2,10 +2,10 @@
--
-- see: https://github.com/sol/hpack
--
--- hash: e0be9f76327041faf731ead5e41e6c3982f3d0b325a0b1b8d19ac514c78dc00e
+-- hash: 3b8d3fcf4859baa5368744ff4c28930ed05d2a9865d2bd9d890b666fbceb84db
name: haskoin-node
-version: 0.9.1
+version: 0.9.2
synopsis: Haskoin Node P2P library for Bitcoin and Bitcoin Cash
description: Bitcoin and Bitcoin Cash peer-to-peer protocol library featuring headers-first synchronisation.
category: Bitcoin, Finance, Network
diff --git a/src/Network/Haskoin/Node/Peer.hs b/src/Network/Haskoin/Node/Peer.hs
index 1a6d95e..acec477 100644
--- a/src/Network/Haskoin/Node/Peer.hs
+++ b/src/Network/Haskoin/Node/Peer.hs
@@ -47,11 +47,10 @@ peer pc inbox = withConnection a $ \ad -> runReaderT (peer_session ad) pc
a = peerConfAddress pc
go = forever $ receive inbox >>= dispatchMessage pc
net = peerConfNetwork pc
- p = inboxToMailbox inbox
peer_session ad =
let ins = appSource ad
ons = appSink ad
- src = runConduit $ ins .| inPeerConduit net a p .| mapM_C send_msg
+ src = runConduit $ ins .| inPeerConduit net a .| mapM_C send_msg
snk = outPeerConduit net .| ons
in withAsync src $ \as -> do
link as
@@ -75,26 +74,25 @@ inPeerConduit ::
MonadLoggerIO m
=> Network
-> SockAddr
- -> Peer
-> ConduitT ByteString Message m ()
-inPeerConduit net a p = forever $ do
+inPeerConduit net a = forever $ do
x <- takeCE 24 .| foldC
case decode x of
Left _ -> do
$(logErrorS)
(peerString a)
"Could not decode incoming message header"
- DecodeHeaderError `killPeer` p
+ throwIO DecodeHeaderError
Right (MessageHeader _ _ len _) -> do
when (len > 32 * 2 ^ (20 :: Int)) $ do
$(logErrorS) (peerString a) "Payload too large"
- PayloadTooLarge len `killPeer` p
+ throwIO $ PayloadTooLarge len
y <- takeCE (fromIntegral len) .| foldC
case runGet (getMessage net) $ x `B.append` y of
Left e -> do
$(logErrorS) (peerString a) $
"Cannot decode payload: " <> cs (show e)
- CannotDecodePayload `killPeer` p
+ throwIO CannotDecodePayload
Right msg -> do
$(logDebugS) (peerString a) $
"Incoming: " <> cs (commandToString (msgType msg))