From 9d3b8a2589aef84472746dd57306b9d07920e073 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 17 Jan 2017 18:33:49 -0500 Subject: Using -- so disabled code is indicated by grep. --- src/Network/BitTorrent/Address.hs | 166 ++++++++++++++------------- src/Network/BitTorrent/DHT/ContactInfo.hs | 182 +++++++++++++++--------------- 2 files changed, 173 insertions(+), 175 deletions(-) (limited to 'src/Network') diff --git a/src/Network/BitTorrent/Address.hs b/src/Network/BitTorrent/Address.hs index f8f29be5..a72a8a07 100644 --- a/src/Network/BitTorrent/Address.hs +++ b/src/Network/BitTorrent/Address.hs @@ -1063,93 +1063,91 @@ libUserAgent = render (pPrint IlibHSbittorrent <> "/" <> pPrint version) -- For torrent file -----------------------------------------------------------------------} -- TODO collect information about createdBy torrent field -{- -renderImpl :: ClientImpl -> Text -renderImpl = T.pack . L.tail . show - -renderVersion :: Version -> Text -renderVersion = undefined +-- renderImpl :: ClientImpl -> Text +-- renderImpl = T.pack . L.tail . show +-- +-- renderVersion :: Version -> Text +-- renderVersion = undefined +-- +-- renderClientInfo :: ClientInfo -> Text +-- renderClientInfo ClientInfo {..} = renderImpl ciImpl <> "/" <> renderVersion ciVersion +-- +-- parseClientInfo :: Text -> ClientImpl +-- parseClientInfo t = undefined -renderClientInfo :: ClientInfo -> Text -renderClientInfo ClientInfo {..} = renderImpl ciImpl <> "/" <> renderVersion ciVersion -parseClientInfo :: Text -> ClientImpl -parseClientInfo t = undefined --} -{- -- code used for generation; remove it later on - -mkEnumTyDef :: NM -> String -mkEnumTyDef = unlines . map (" | I" ++) . nub . map snd - -mkPars :: NM -> String -mkPars = unlines . map (\(code, impl) -> " f \"" ++ code ++ "\" = " ++ "I" ++ impl) - -type NM = [(String, String)] -nameMap :: NM -nameMap = - [ ("AG", "Ares") - , ("A~", "Ares") - , ("AR", "Arctic") - , ("AV", "Avicora") - , ("AX", "BitPump") - , ("AZ", "Azureus") - , ("BB", "BitBuddy") - , ("BC", "BitComet") - , ("BF", "Bitflu") - , ("BG", "BTG") - , ("BR", "BitRocket") - , ("BS", "BTSlave") - , ("BX", "BittorrentX") - , ("CD", "EnhancedCTorrent") - , ("CT", "CTorrent") - , ("DE", "DelugeTorrent") - , ("DP", "PropagateDataClient") - , ("EB", "EBit") - , ("ES", "ElectricSheep") - , ("FT", "FoxTorrent") - , ("GS", "GSTorrent") - , ("HL", "Halite") - , ("HS", "libHSnetwork_bittorrent") - , ("HN", "Hydranode") - , ("KG", "KGet") - , ("KT", "KTorrent") - , ("LH", "LH_ABC") - , ("LP", "Lphant") - , ("LT", "Libtorrent") - , ("lt", "LibTorrent") - , ("LW", "LimeWire") - , ("MO", "MonoTorrent") - , ("MP", "MooPolice") - , ("MR", "Miro") - , ("MT", "MoonlightTorrent") - , ("NX", "NetTransport") - , ("PD", "Pando") - , ("qB", "qBittorrent") - , ("QD", "QQDownload") - , ("QT", "Qt4TorrentExample") - , ("RT", "Retriever") - , ("S~", "Shareaza") - , ("SB", "Swiftbit") - , ("SS", "SwarmScope") - , ("ST", "SymTorrent") - , ("st", "sharktorrent") - , ("SZ", "Shareaza") - , ("TN", "TorrentDotNET") - , ("TR", "Transmission") - , ("TS", "Torrentstorm") - , ("TT", "TuoTu") - , ("UL", "uLeecher") - , ("UT", "uTorrent") - , ("VG", "Vagaa") - , ("WT", "BitLet") - , ("WY", "FireTorrent") - , ("XL", "Xunlei") - , ("XT", "XanTorrent") - , ("XX", "Xtorrent") - , ("ZT", "ZipTorrent") - ] --} +-- +-- mkEnumTyDef :: NM -> String +-- mkEnumTyDef = unlines . map (" | I" ++) . nub . map snd +-- +-- mkPars :: NM -> String +-- mkPars = unlines . map (\(code, impl) -> " f \"" ++ code ++ "\" = " ++ "I" ++ impl) +-- +-- type NM = [(String, String)] +-- nameMap :: NM +-- nameMap = +-- [ ("AG", "Ares") +-- , ("A~", "Ares") +-- , ("AR", "Arctic") +-- , ("AV", "Avicora") +-- , ("AX", "BitPump") +-- , ("AZ", "Azureus") +-- , ("BB", "BitBuddy") +-- , ("BC", "BitComet") +-- , ("BF", "Bitflu") +-- , ("BG", "BTG") +-- , ("BR", "BitRocket") +-- , ("BS", "BTSlave") +-- , ("BX", "BittorrentX") +-- , ("CD", "EnhancedCTorrent") +-- , ("CT", "CTorrent") +-- , ("DE", "DelugeTorrent") +-- , ("DP", "PropagateDataClient") +-- , ("EB", "EBit") +-- , ("ES", "ElectricSheep") +-- , ("FT", "FoxTorrent") +-- , ("GS", "GSTorrent") +-- , ("HL", "Halite") +-- , ("HS", "libHSnetwork_bittorrent") +-- , ("HN", "Hydranode") +-- , ("KG", "KGet") +-- , ("KT", "KTorrent") +-- , ("LH", "LH_ABC") +-- , ("LP", "Lphant") +-- , ("LT", "Libtorrent") +-- , ("lt", "LibTorrent") +-- , ("LW", "LimeWire") +-- , ("MO", "MonoTorrent") +-- , ("MP", "MooPolice") +-- , ("MR", "Miro") +-- , ("MT", "MoonlightTorrent") +-- , ("NX", "NetTransport") +-- , ("PD", "Pando") +-- , ("qB", "qBittorrent") +-- , ("QD", "QQDownload") +-- , ("QT", "Qt4TorrentExample") +-- , ("RT", "Retriever") +-- , ("S~", "Shareaza") +-- , ("SB", "Swiftbit") +-- , ("SS", "SwarmScope") +-- , ("ST", "SymTorrent") +-- , ("st", "sharktorrent") +-- , ("SZ", "Shareaza") +-- , ("TN", "TorrentDotNET") +-- , ("TR", "Transmission") +-- , ("TS", "Torrentstorm") +-- , ("TT", "TuoTu") +-- , ("UL", "uLeecher") +-- , ("UT", "uTorrent") +-- , ("VG", "Vagaa") +-- , ("WT", "BitLet") +-- , ("WY", "FireTorrent") +-- , ("XL", "Xunlei") +-- , ("XT", "XanTorrent") +-- , ("XX", "Xtorrent") +-- , ("ZT", "ZipTorrent") +-- ] -- TODO use regexps diff --git a/src/Network/BitTorrent/DHT/ContactInfo.hs b/src/Network/BitTorrent/DHT/ContactInfo.hs index 4293506d..d7c92e35 100644 --- a/src/Network/BitTorrent/DHT/ContactInfo.hs +++ b/src/Network/BitTorrent/DHT/ContactInfo.hs @@ -13,97 +13,97 @@ import Data.Serialize import Data.Torrent import Network.BitTorrent.Address -{- -import Data.HashMap.Strict as HM - -import Data.Torrent.InfoHash -import Network.BitTorrent.Address - --- increase prefix when table is too large --- decrease prefix when table is too small --- filter outdated peers - -{----------------------------------------------------------------------- --- PeerSet ------------------------------------------------------------------------} - -type PeerSet a = [(PeerAddr a, NodeInfo a, Timestamp)] - --- compare PSQueue vs Ordered list - -takeNewest :: PeerSet a -> [PeerAddr a] -takeNewest = undefined - -dropOld :: Timestamp -> PeerSet a -> PeerSet a -dropOld = undefined - -insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a -insert = undefined - -type Mask = Int -type Size = Int -type Timestamp = Int - -{----------------------------------------------------------------------- --- InfoHashMap ------------------------------------------------------------------------} - --- compare handwritten prefix tree versus IntMap - -data Tree a - = Nil - | Tip !InfoHash !(PeerSet a) - | Bin !InfoHash !Mask !Size !Timestamp (Tree a) (Tree a) - -insertTree :: InfoHash -> a -> Tree a -> Tree a -insertTree = undefined - -type Prio = Int - ---shrink :: ContactInfo ip -> Int -shrink Nil = Nil -shrink (Tip _ _) = undefined -shrink (Bin _ _) = undefined - -{----------------------------------------------------------------------- --- InfoHashMap ------------------------------------------------------------------------} - --- compare new design versus HashMap - -data IntMap k p a -type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp) - -data ContactInfo ip = PeerStore - { maxSize :: Int - , prefixSize :: Int - , thisNodeId :: NodeId - - , count :: Int -- ^ Cached size of the 'peerSet' - , peerSet :: HashMap InfoHash [PeerAddr ip] - } - -size :: ContactInfo ip -> Int -size = undefined - -prefixSize :: ContactInfo ip -> Int -prefixSize = undefined - -lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip] -lookup = undefined - -insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip -insert = undefined - --- | Limit in size. -prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip -prune pref targetSize Nil = Nil -prune pref targetSize (Tip _ _) = undefined - --- | Remove expired entries. -splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip -splitGT = undefined --} +-- {- +-- import Data.HashMap.Strict as HM +-- +-- import Data.Torrent.InfoHash +-- import Network.BitTorrent.Address +-- +-- -- increase prefix when table is too large +-- -- decrease prefix when table is too small +-- -- filter outdated peers +-- +-- {----------------------------------------------------------------------- +-- -- PeerSet +-- -----------------------------------------------------------------------} +-- +-- type PeerSet a = [(PeerAddr a, NodeInfo a, Timestamp)] +-- +-- -- compare PSQueue vs Ordered list +-- +-- takeNewest :: PeerSet a -> [PeerAddr a] +-- takeNewest = undefined +-- +-- dropOld :: Timestamp -> PeerSet a -> PeerSet a +-- dropOld = undefined +-- +-- insert :: PeerAddr a -> Timestamp -> PeerSet a -> PeerSet a +-- insert = undefined +-- +-- type Mask = Int +-- type Size = Int +-- type Timestamp = Int +-- +-- {----------------------------------------------------------------------- +-- -- InfoHashMap +-- -----------------------------------------------------------------------} +-- +-- -- compare handwritten prefix tree versus IntMap +-- +-- data Tree a +-- = Nil +-- | Tip !InfoHash !(PeerSet a) +-- | Bin !InfoHash !Mask !Size !Timestamp (Tree a) (Tree a) +-- +-- insertTree :: InfoHash -> a -> Tree a -> Tree a +-- insertTree = undefined +-- +-- type Prio = Int +-- +-- --shrink :: ContactInfo ip -> Int +-- shrink Nil = Nil +-- shrink (Tip _ _) = undefined +-- shrink (Bin _ _) = undefined +-- +-- {----------------------------------------------------------------------- +-- -- InfoHashMap +-- -----------------------------------------------------------------------} +-- +-- -- compare new design versus HashMap +-- +-- data IntMap k p a +-- type ContactInfo = Map InfoHash Timestamp (Set (PeerAddr IP) Timestamp) +-- +-- data ContactInfo ip = PeerStore +-- { maxSize :: Int +-- , prefixSize :: Int +-- , thisNodeId :: NodeId +-- +-- , count :: Int -- ^ Cached size of the 'peerSet' +-- , peerSet :: HashMap InfoHash [PeerAddr ip] +-- } +-- +-- size :: ContactInfo ip -> Int +-- size = undefined +-- +-- prefixSize :: ContactInfo ip -> Int +-- prefixSize = undefined +-- +-- lookup :: InfoHash -> ContactInfo ip -> [PeerAddr ip] +-- lookup = undefined +-- +-- insert :: InfoHash -> PeerAddr ip -> ContactInfo ip -> ContactInfo ip +-- insert = undefined +-- +-- -- | Limit in size. +-- prune :: NodeId -> Int -> ContactInfo ip -> ContactInfo ip +-- prune pref targetSize Nil = Nil +-- prune pref targetSize (Tip _ _) = undefined +-- +-- -- | Remove expired entries. +-- splitGT :: Timestamp -> ContactInfo ip -> ContactInfo ip +-- splitGT = undefined +-- -} -- | Storage used to keep track a set of known peers in client, -- tracker or DHT sessions. -- cgit v1.2.3