summaryrefslogtreecommitdiff
path: root/src/Identity.hs
blob: 65fec8a04b0c9107ed4010277163d0919bacf634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Identity (
    Identity, IdentityData(..),
) where

import Data.Text (Text)

import PubKey
import Storage

type Identity = Signed IdentityData

data IdentityData = Identity
    { idName :: Text
    , idPrev :: Maybe (Stored Identity)
    , idKeyIdentity :: Stored PublicKey
    }
    deriving (Show)

instance Storable IdentityData where
    store' idt = storeRec $ do
        storeText "name" $ idName idt
        storeMbRef "prev" $ idPrev idt
        storeRef "key-id" $ idKeyIdentity idt

    load' = loadRec $ Identity
        <$> loadText "name"
        <*> loadMbRef "prev"
        <*> loadRef "key-id"