summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/Exchange/Wire.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Exchange/Wire.hs b/src/Network/BitTorrent/Exchange/Wire.hs
index 427d7676..0897f482 100644
--- a/src/Network/BitTorrent/Exchange/Wire.hs
+++ b/src/Network/BitTorrent/Exchange/Wire.hs
@@ -426,6 +426,28 @@ instance Default Options where
426-- Connection 426-- Connection
427-----------------------------------------------------------------------} 427-----------------------------------------------------------------------}
428 428
429data Cached a = Cached { unCache :: a, cached :: BS.ByteString }
430
431cache :: (BEncode a) => a -> Cached a
432cache s = Cached s (BSL.toStrict $ BE.encode s)
433
434data ConnectionState = ConnectionState {
435 -- | If @not (allowed ExtExtended connCaps)@ then this set is always
436 -- empty. Otherwise it has the BEP10 extension protocol mandated mapping of
437 -- 'MessageId' to the message type for the remote peer.
438 _connExtCaps :: !ExtendedCaps
439
440 -- | Current extended handshake information from the remote peer
441 , _connRemoteEhs :: !ExtendedHandshake
442
443 -- | Various stats about messages sent and received. Stats can be
444 -- used to protect /this/ peer against flood attacks.
445 , _connStats :: !ConnectionStats
446
447 -- | Infodict associated with this Connection's connTopic.
448 , _connMetadata :: Maybe (Cached InfoDict)
449 }
450
429-- | Connection keep various info about both peers. 451-- | Connection keep various info about both peers.
430data Connection = Connection 452data Connection = Connection
431 { -- | /Both/ peers handshaked with this protocol string. The only 453 { -- | /Both/ peers handshaked with this protocol string. The only