diff options
Diffstat (limited to 'src/Data/Torrent/Bitfield.hs')
-rw-r--r-- | src/Data/Torrent/Bitfield.hs | 5 |
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) | |||
135 | null :: Bitfield -> Bool | 136 | null :: Bitfield -> Bool |
136 | null Bitfield {..} = S.null bfSet | 137 | null Bitfield {..} = S.null bfSet |
137 | 138 | ||
139 | -- | Test if bitfield have all pieces. | ||
140 | full :: Bitfield -> Bool | ||
141 | full Bitfield {..} = S.size bfSet == bfSize | ||
142 | |||
138 | -- | Count of peer have pieces. | 143 | -- | Count of peer have pieces. |
139 | haveCount :: Bitfield -> PieceCount | 144 | haveCount :: Bitfield -> PieceCount |
140 | haveCount = S.size . bfSet | 145 | haveCount = S.size . bfSet |