From 8248099300f9eb33466ea9d13ac039b187576de6 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sun, 5 Jan 2014 01:19:51 +0400 Subject: Add Bitfield.full function --- src/Data/Torrent/Bitfield.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Data/Torrent/Bitfield.hs') 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 -- * Query , Data.Torrent.Bitfield.null + , Data.Torrent.Bitfield.full , haveCount, totalCount, completeness , member, notMember @@ -135,6 +136,10 @@ interval pc a b = Bitfield pc (S.interval a b) null :: Bitfield -> Bool null Bitfield {..} = S.null bfSet +-- | Test if bitfield have all pieces. +full :: Bitfield -> Bool +full Bitfield {..} = S.size bfSet == bfSize + -- | Count of peer have pieces. haveCount :: Bitfield -> PieceCount haveCount = S.size . bfSet -- cgit v1.2.3