summaryrefslogtreecommitdiff
path: root/src/Identity.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Identity.hs')
-rw-r--r--src/Identity.hs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Identity.hs b/src/Identity.hs
index 65fec8a..07356d8 100644
--- a/src/Identity.hs
+++ b/src/Identity.hs
@@ -1,5 +1,6 @@
module Identity (
Identity, IdentityData(..),
+ emptyIdentity,
) where
import Data.Text (Text)
@@ -10,19 +11,30 @@ import Storage
type Identity = Signed IdentityData
data IdentityData = Identity
- { idName :: Text
+ { idName :: Maybe Text
, idPrev :: Maybe (Stored Identity)
+ , idOwner :: Maybe (Stored Identity)
, idKeyIdentity :: Stored PublicKey
}
deriving (Show)
+emptyIdentity :: Stored PublicKey -> IdentityData
+emptyIdentity key = Identity
+ { idName = Nothing
+ , idPrev = Nothing
+ , idOwner = Nothing
+ , idKeyIdentity = key
+ }
+
instance Storable IdentityData where
store' idt = storeRec $ do
- storeText "name" $ idName idt
+ storeMbText "name" $ idName idt
storeMbRef "prev" $ idPrev idt
+ storeMbRef "owner" $ idOwner idt
storeRef "key-id" $ idKeyIdentity idt
load' = loadRec $ Identity
- <$> loadText "name"
+ <$> loadMbText "name"
<*> loadMbRef "prev"
+ <*> loadMbRef "owner"
<*> loadRef "key-id"