summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Exchange/Session.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-26 08:00:16 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-26 08:00:16 +0400
commit8526ebaa230d98f70654e6bcfc64dcd511712f7b (patch)
tree0e8d3b10dd400bb982cffb574c5287a6d9351042 /src/Network/BitTorrent/Exchange/Session.hs
parent1c38e5857764fe2ab8cb5ec55b31f13239278599 (diff)
Minor refactoring
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Session.hs')
-rw-r--r--src/Network/BitTorrent/Exchange/Session.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/Exchange/Session.hs b/src/Network/BitTorrent/Exchange/Session.hs
index be8d3835..921571f5 100644
--- a/src/Network/BitTorrent/Exchange/Session.hs
+++ b/src/Network/BitTorrent/Exchange/Session.hs
@@ -12,6 +12,9 @@ module Network.BitTorrent.Exchange.Session
12 , Network.BitTorrent.Exchange.Session.attach 12 , Network.BitTorrent.Exchange.Session.attach
13 , Network.BitTorrent.Exchange.Session.delete 13 , Network.BitTorrent.Exchange.Session.delete
14 , Network.BitTorrent.Exchange.Session.deleteAll 14 , Network.BitTorrent.Exchange.Session.deleteAll
15
16 -- * Events
17 , waitMetadata
15 ) where 18 ) where
16 19
17import Control.Applicative 20import Control.Applicative
@@ -86,12 +89,11 @@ data Session = Session
86 , status :: !(MVar SessionStatus) 89 , status :: !(MVar SessionStatus)
87 , storage :: !(Storage) 90 , storage :: !(Storage)
88 91
89 , broadcast :: !(Chan Message)
90
91 , unchoked :: [PeerAddr IP]
92 , connectionsPrefs :: !ConnectionPrefs 92 , connectionsPrefs :: !ConnectionPrefs
93 , connectionsPending :: !(TVar (Set (PeerAddr IP))) 93 , connectionsPending :: !(TVar (Set (PeerAddr IP)))
94 , connectionsEstablished :: !(TVar (Map (PeerAddr IP) (Connection Session))) 94 , connectionsEstablished :: !(TVar (Map (PeerAddr IP) (Connection Session)))
95 , connectionsUnchoked :: [PeerAddr IP]
96 , broadcast :: !(Chan Message)
95 97
96 , logger :: !(LogFun) 98 , logger :: !(LogFun)
97 } 99 }
@@ -117,16 +119,20 @@ newSession logFun addr rootPath dict = do
117 return Session 119 return Session
118 { sessionPeerId = pid 120 { sessionPeerId = pid
119 , sessionTopic = idInfoHash dict 121 , sessionTopic = idInfoHash dict
122
123 , metadata = undefined
124 , infodict = undefined
125
120 , status = statusVar 126 , status = statusVar
121 , storage = store 127 , storage = store
122 , unchoked = [] 128
123 , connectionsPrefs = def 129 , connectionsPrefs = def
124 , connectionsPending = pconnVar 130 , connectionsPending = pconnVar
125 , connectionsEstablished = econnVar 131 , connectionsEstablished = econnVar
132 , connectionsUnchoked = []
126 , broadcast = chan 133 , broadcast = chan
134
127 , logger = logFun 135 , logger = logFun
128 , metadata = undefined
129 , infodict = undefined
130 } 136 }
131 137
132closeSession :: Session -> IO () 138closeSession :: Session -> IO ()
@@ -134,6 +140,9 @@ closeSession ses = do
134 deleteAll ses 140 deleteAll ses
135 undefined 141 undefined
136 142
143waitMetadata :: Session -> IO InfoDict
144waitMetadata Session {..} = cachedValue <$> readMVar infodict
145
137{----------------------------------------------------------------------- 146{-----------------------------------------------------------------------
138-- Logging 147-- Logging
139-----------------------------------------------------------------------} 148-----------------------------------------------------------------------}