diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-05 01:19:51 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-05 01:19:51 +0400 |
commit | 8248099300f9eb33466ea9d13ac039b187576de6 (patch) | |
tree | ee50f7aeec508d54a4a919d25b43397261ef1338 /src/Data/Torrent | |
parent | 9577747c3ad7ba380bc5f8d4cc6a4a5420bdacae (diff) |
Add Bitfield.full function
Diffstat (limited to 'src/Data/Torrent')
-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 |