forked from schmittlauch/Hash2Pub
deserialisation of DHT messages
This commit is contained in:
parent
c9654d66d6
commit
6dc9650da5
|
@ -4,14 +4,16 @@ module Hash2Pub.ASN1Coding where
|
|||
|
||||
import Data.ASN1.Encoding -- asn1-encoding package
|
||||
import Data.ASN1.BinaryEncoding
|
||||
import Data.ASN1.Error
|
||||
import Data.ASN1.Error()
|
||||
import Data.ASN1.Types -- asn1-types package
|
||||
import Data.ASN1.Parse
|
||||
import Data.Maybe (fromMaybe, mapMaybe)
|
||||
import Data.Time.Clock.POSIX
|
||||
import Data.Time.Clock.POSIX()
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.Map.Strict as Map
|
||||
import qualified Data.Map.Strict as Map()
|
||||
import Data.Bifunctor (first)
|
||||
import Control.Exception (displayException)
|
||||
import Safe
|
||||
|
||||
import Hash2Pub.FediChord
|
||||
|
@ -159,6 +161,11 @@ serialiseMessage msg maxBytesLength =
|
|||
maxMsgLength msgs = maximum $ map BS.length msgs
|
||||
maximumParts = 150
|
||||
|
||||
-- | Deserialise a ASN.1 DER encoded bytesstring of a single 'FediChordMessage'.
|
||||
deserialiseMessage :: BS.ByteString
|
||||
-> Either String FediChordMessage
|
||||
deserialiseMessage msgBytes = first displayException (decodeASN1' DER msgBytes) >>= runParseASN1 parseMessage
|
||||
|
||||
-- ===== encoding functions =====
|
||||
|
||||
-- encode a message 'ActionPayload' according to its type,
|
||||
|
|
Loading…
Reference in a new issue