summaryrefslogtreecommitdiff
path: root/src/Data/Torrent
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-01-05 01:19:51 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-01-05 01:19:51 +0400
commit8248099300f9eb33466ea9d13ac039b187576de6 (patch)
treeee50f7aeec508d54a4a919d25b43397261ef1338 /src/Data/Torrent
parent9577747c3ad7ba380bc5f8d4cc6a4a5420bdacae (diff)
Add Bitfield.full function
Diffstat (limited to 'src/Data/Torrent')
-rw-r--r--src/Data/Torrent/Bitfield.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Data/Torrent/Bitfield.hs b/src/Data/Torrent/Bitfield.hs
index 176ba2c0..d564e353 100644
--- a/src/Data/Torrent/Bitfield.hs
+++ b/src/Data/Torrent/Bitfield.hs
@@ -37,6 +37,7 @@ module Data.Torrent.Bitfield
37 37
38 -- * Query 38 -- * Query
39 , Data.Torrent.Bitfield.null 39 , Data.Torrent.Bitfield.null
40 , Data.Torrent.Bitfield.full
40 , haveCount, totalCount, completeness 41 , haveCount, totalCount, completeness
41 42
42 , member, notMember 43 , member, notMember
@@ -135,6 +136,10 @@ interval pc a b = Bitfield pc (S.interval a b)
135null :: Bitfield -> Bool 136null :: Bitfield -> Bool
136null Bitfield {..} = S.null bfSet 137null Bitfield {..} = S.null bfSet
137 138
139-- | Test if bitfield have all pieces.
140full :: Bitfield -> Bool
141full Bitfield {..} = S.size bfSet == bfSize
142
138-- | Count of peer have pieces. 143-- | Count of peer have pieces.
139haveCount :: Bitfield -> PieceCount 144haveCount :: Bitfield -> PieceCount
140haveCount = S.size . bfSet 145haveCount = S.size . bfSet