blob: c1561b620cd8b1a88a1721204b7a053f1e74578b (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
module Identity (
Identity, IdentityData(..),
emptyIdentity,
) where
import Data.Text (Text)
import PubKey
import Storage
type Identity = Signed IdentityData
data IdentityData = Identity
{ idName :: Maybe Text
, idPrev :: Maybe (Stored Identity)
, idOwner :: Maybe (Stored Identity)
, idKeyIdentity :: Stored PublicKey
, idKeyMessage :: Stored PublicKey
}
deriving (Show)
emptyIdentity :: Stored PublicKey -> Stored PublicKey -> IdentityData
emptyIdentity key kmsg = Identity
{ idName = Nothing
, idPrev = Nothing
, idOwner = Nothing
, idKeyIdentity = key
, idKeyMessage = kmsg
}
instance Storable IdentityData where
store' idt = storeRec $ do
storeMbText "name" $ idName idt
storeMbRef "prev" $ idPrev idt
storeMbRef "owner" $ idOwner idt
storeRef "key-id" $ idKeyIdentity idt
storeRef "key-msg" $ idKeyMessage idt
load' = loadRec $ Identity
<$> loadMbText "name"
<*> loadMbRef "prev"
<*> loadMbRef "owner"
<*> loadRef "key-id"
<*> loadRef "key-msg"
|