diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/Exchange.hs | 13 | ||||
-rw-r--r-- | src/Network/BitTorrent/Exchange/Protocol.hs | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/Network/BitTorrent/Exchange.hs b/src/Network/BitTorrent/Exchange.hs index 9f119d13..b0a94853 100644 --- a/src/Network/BitTorrent/Exchange.hs +++ b/src/Network/BitTorrent/Exchange.hs | |||
@@ -79,7 +79,8 @@ import Control.Monad.Trans.Resource | |||
79 | 79 | ||
80 | import Data.IORef | 80 | import Data.IORef |
81 | import Data.Conduit as C | 81 | import Data.Conduit as C |
82 | import Data.Conduit.Cereal | 82 | import Data.Conduit.Cereal as S |
83 | import Data.Conduit.Serialization.Binary as B | ||
83 | import Data.Conduit.Network | 84 | import Data.Conduit.Network |
84 | import Data.Serialize as S | 85 | import Data.Serialize as S |
85 | import Text.PrettyPrint as PP hiding (($$)) | 86 | import Text.PrettyPrint as PP hiding (($$)) |
@@ -103,10 +104,12 @@ type PeerWire = ConduitM Message Message IO | |||
103 | 104 | ||
104 | runPeerWire :: Socket -> PeerWire () -> IO () | 105 | runPeerWire :: Socket -> PeerWire () -> IO () |
105 | runPeerWire sock p2p = | 106 | runPeerWire sock p2p = |
106 | sourceSocket sock $= | 107 | sourceSocket sock $= |
107 | conduitGet S.get $= | 108 | S.conduitGet S.get $= |
108 | p2p $= | 109 | -- B.conduitDecode $= |
109 | conduitPut S.put $$ | 110 | p2p $= |
111 | S.conduitPut S.put $$ | ||
112 | -- B.conduitEncode $$ | ||
110 | sinkSocket sock | 113 | sinkSocket sock |
111 | 114 | ||
112 | awaitMessage :: P2P Message | 115 | awaitMessage :: P2P Message |
diff --git a/src/Network/BitTorrent/Exchange/Protocol.hs b/src/Network/BitTorrent/Exchange/Protocol.hs index 83774f06..a285f8d2 100644 --- a/src/Network/BitTorrent/Exchange/Protocol.hs +++ b/src/Network/BitTorrent/Exchange/Protocol.hs | |||
@@ -435,7 +435,7 @@ instance Serialize Message where | |||
435 | 435 | ||
436 | instance Binary Message where | 436 | instance Binary Message where |
437 | get = do | 437 | get = do |
438 | len <- undefined --getInt | 438 | len <- getIntB |
439 | -- _ <- lookAhead $ ensure len | 439 | -- _ <- lookAhead $ ensure len |
440 | if len == 0 then return KeepAlive | 440 | if len == 0 then return KeepAlive |
441 | else do | 441 | else do |
@@ -463,7 +463,7 @@ instance Binary Message where | |||
463 | 463 | ||
464 | where | 464 | where |
465 | getBlock :: Int -> B.Get Block | 465 | getBlock :: Int -> B.Get Block |
466 | getBlock len = Block <$> getIntB <*> getIntB <*> B.getBytes len | 466 | getBlock len = Block <$> getIntB <*> getIntB <*> B.getByteString len |
467 | {-# INLINE getBlock #-} | 467 | {-# INLINE getBlock #-} |
468 | 468 | ||
469 | put KeepAlive = putIntB 0 | 469 | put KeepAlive = putIntB 0 |