, infoHash :: !ByteString
} deriving (Eq, Show)
-mkInfo :: BVal -> Maybe Info
-mkInfo (Bdict m) = let (Bint pieceLength') = m ! "piece length"
- (Bstr pieces') = m ! "pieces"
- private' = Nothing
- (Bstr name') = m ! "name"
- (Bint length') = m ! "length"
- md5sum' = Nothing
- in Just Info { pieceLength = pieceLength'
- , pieces = pieces'
- , private = private'
- , name = unpack name'
- , lengthInBytes = length'
- , md5sum = md5sum'}
-mkInfo _ = Nothing
+bvalToInfo :: BVal -> Maybe Info
+bvalToInfo (Bdict m) = let (Bint pieceLength') = m ! "piece length"
+ (Bstr pieces') = m ! "pieces"
+ private' = Nothing
+ (Bstr name') = m ! "name"
+ (Bint length') = m ! "length"
+ md5sum' = Nothing
+ in Just Info { pieceLength = pieceLength'
+ , pieces = pieces'
+ , private = private'
+ , name = unpack name'
+ , lengthInBytes = length'
+ , md5sum = md5sum'}
+bvalToInfo _ = Nothing
mkMetaInfo :: BVal -> Either String Metainfo
mkMetaInfo (Bdict m) =
- let info' = mkInfo $ m ! "info"
+ let info' = bvalToInfo $ m ! "info"
announce' = lookup "announce" m
announceList' = lookup "announce-list" m
creationDate' = lookup "creation date" m