diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2019-05-06 21:58:39 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2019-05-06 21:58:39 +0200 |
commit | 0fb19186ddd80ae71d694071ed56d192e5bb942c (patch) | |
tree | 7f76c27171c502564789f69cf73680ca65595cfb /src/Identity.hs | |
parent | 1c7e875f67e31c68e76c660294b67078acd4f38f (diff) |
Distinct device and owner identities
Diffstat (limited to 'src/Identity.hs')
-rw-r--r-- | src/Identity.hs | 18 |
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" |