summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-16 20:44:34 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-16 20:44:34 +0400
commit4f34289c4c652d312667cd0cc3bf1660b907f707 (patch)
tree2013eda1533c5c13720ed7d1997708bd6fb12a3b
parent635629e9274618a637014685011b289e84d774cc (diff)
Add isBootstrapped function
-rw-r--r--src/Network/BitTorrent/DHT.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/DHT.hs b/src/Network/BitTorrent/DHT.hs
index 4dd8c801..3b852c52 100644
--- a/src/Network/BitTorrent/DHT.hs
+++ b/src/Network/BitTorrent/DHT.hs
@@ -28,6 +28,7 @@ module Network.BitTorrent.DHT
28 , defaultBootstrapNodes 28 , defaultBootstrapNodes
29 , resolveHostName 29 , resolveHostName
30 , bootstrap 30 , bootstrap
31 , isBootstrapped
31 32
32 -- * Initialization 33 -- * Initialization
33 , snapshot 34 , snapshot
@@ -59,6 +60,7 @@ import Data.Torrent (tNodes)
59import Data.Torrent.InfoHash 60import Data.Torrent.InfoHash
60import Network.BitTorrent.Core 61import Network.BitTorrent.Core
61import Network.BitTorrent.DHT.Session 62import Network.BitTorrent.DHT.Session
63import Network.BitTorrent.DHT.Routing as T
62 64
63{----------------------------------------------------------------------- 65{-----------------------------------------------------------------------
64-- DHT types 66-- DHT types
@@ -133,6 +135,14 @@ bootstrap startNodes = do
133 _ <- sourceList [aliveNodes] $= search nid (findNodeQ nid) $$ C.consume 135 _ <- sourceList [aliveNodes] $= search nid (findNodeQ nid) $$ C.consume
134 $(logInfoS) "bootstrap" "Node bootstrapping finished" 136 $(logInfoS) "bootstrap" "Node bootstrapping finished"
135 137
138-- | Check if this node is already bootstrapped.
139-- @bootstrap [good_node] >> isBootstrapped@@ should always return 'True'.
140--
141-- This operation do not block.
142--
143isBootstrapped :: DHT ip Bool
144isBootstrapped = T.full <$> getTable
145
136{----------------------------------------------------------------------- 146{-----------------------------------------------------------------------
137-- Initialization 147-- Initialization
138-----------------------------------------------------------------------} 148-----------------------------------------------------------------------}