From 4f34289c4c652d312667cd0cc3bf1660b907f707 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sun, 16 Feb 2014 20:44:34 +0400 Subject: Add isBootstrapped function --- src/Network/BitTorrent/DHT.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 , defaultBootstrapNodes , resolveHostName , bootstrap + , isBootstrapped -- * Initialization , snapshot @@ -59,6 +60,7 @@ import Data.Torrent (tNodes) import Data.Torrent.InfoHash import Network.BitTorrent.Core import Network.BitTorrent.DHT.Session +import Network.BitTorrent.DHT.Routing as T {----------------------------------------------------------------------- -- DHT types @@ -133,6 +135,14 @@ bootstrap startNodes = do _ <- sourceList [aliveNodes] $= search nid (findNodeQ nid) $$ C.consume $(logInfoS) "bootstrap" "Node bootstrapping finished" +-- | Check if this node is already bootstrapped. +-- @bootstrap [good_node] >> isBootstrapped@@ should always return 'True'. +-- +-- This operation do not block. +-- +isBootstrapped :: DHT ip Bool +isBootstrapped = T.full <$> getTable + {----------------------------------------------------------------------- -- Initialization -----------------------------------------------------------------------} -- cgit v1.2.3